:root {
    --room-size: 80px;
    --portal-thickness: 10px;
    --portal-length: 40px;
    --color-ne: #0074d9;
    --color-se: #2ecc40;
    --color-sw: #ff851b;
    --color-nw: #b10dc9;
    /*--color-special-exit: #ff4136;*/
    --color-special-exit: #ffdc00;
    --color-special-kr: #ffdc00;
}

* {
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    padding: 1.5rem;
    background: #111827;
    color: #e5e7eb;
}

h1 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
    text-align: center;
}

h4 {
    text-align: center;
}

.accordion {
    max-width: 1600px;
    margin: 0 auto;
}

.maze-set {
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    overflow: visible;
    border: 1px solid #374151;
    background: #020617;
}

.maze-set-header {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    background: #111827;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    color: inherit;
    font-size: 0.95rem;
}

.maze-set-header span.title {
    font-weight: 600;
}

.maze-set-header span.meta {
    font-size: 0.8rem;
    color: #9ca3af;
}

.maze-set-header:hover {
    background: #0f172a;
}

.maze-set-body {
    display: none;
    padding: 2rem 1.5rem;
    border-top: 1px solid #1f2937;
    background: #020617;
}

.maze-set.open .maze-set-body {
    display: block;
}

.maze-set-content {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 1.5rem;
    flex-wrap: nowrap;
    min-width: min-content;
}

.room-row {
    display: flex;
    flex-direction: row;
    gap: 1.25rem;
    flex-wrap: nowrap;
    flex-shrink: 0;
    align-items: center;
    min-width: min-content;
}

.room-wrapper {
    position: relative;
    width: calc(var(--room-size) * 1.5);
    height: calc(var(--room-size) * 1.5);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.room {
    cursor: pointer;
    width: var(--room-size);
    height: var(--room-size);
    position: relative;
    pointer-events: auto;
}

.room * {
    pointer-events: none;
}

.room-diamond {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(45deg);
    border: 4px solid #4b5563;
    background: #020617;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.1s, background-color 0.1s;
    z-index: 2;
    overflow: hidden;
}

.room-diamond-inner {
    transform: rotate(-45deg);
    text-align: center;
    font-size: 0.75rem;
    line-height: 1.2;
    color: #e5e7eb;
}

.room-number {
    font-size: 1rem;
    font-weight: 600;
    display: block;
}

.room-desc {
    font-size: 0.65rem;
    color: #9ca3af;
}

.room.active .room-diamond {
    border-color: #e5e7eb;
}

.room-destination {
    box-shadow: 0 0 0 2px #e5e7eb;
}

.room-destination-ne {
    border-color: var(--color-ne);
}
.room-destination-se {
    border-color: var(--color-se);
}
.room-destination-sw {
    border-color: var(--color-sw);
}
.room-destination-nw {
    border-color: var(--color-nw);
}
.room-wrapper:nth-child(9) > .room > .room-destination {
    border-color: var(--color-special-kr);
}

/* Portals - positioned on the actual diamond edges */
.portal {
    position: absolute;
    width: var(--portal-length);
    height: var(--portal-thickness);
    background: transparent;
    border-radius: 999px;
    pointer-events: none;
    transition: background 0.1s;
    z-index: 1;
}

/* NE edge - top right (UP) */
.portal-ne {
    top: calc(50% - var(--room-size) / 2 * 0.707);
    right: calc(50% - var(--room-size) / 2 * 0.707);
    transform: translate(50%, -50%) rotate(-45deg);
    transform-origin: center;
}

/* SE edge - bottom right (RIGHT) */
.portal-se {
    bottom: calc(50% - var(--room-size) / 2 * 0.707);
    right: calc(50% - var(--room-size) / 2 * 0.707);
    transform: translate(50%, 50%) rotate(45deg);
    transform-origin: center;
}

/* SW edge - bottom left (DOWN) */
.portal-sw {
    bottom: calc(50% - var(--room-size) / 2 * 0.707);
    left: calc(50% - var(--room-size) / 2 * 0.707);
    transform: translate(-50%, 50%) rotate(-45deg);
    transform-origin: center;
}

/* NW edge - top left (LEFT) */
.portal-nw {
    top: calc(50% - var(--room-size) / 2 * 0.707);
    left: calc(50% - var(--room-size) / 2 * 0.707);
    transform: translate(-50%, -50%) rotate(45deg);
    transform-origin: center;
}

.portal-ne.active {
    background: var(--color-ne);
}
.portal-se.active {
    background: var(--color-se);
}
.portal-sw.active {
    background: var(--color-sw);
}
.portal-nw.active {
    background: var(--color-nw);
}

/* Override active colors for special portals */
.portal-special:not(.portal-exit) {
    background: var(--color-special-kr) !important;
}

.portal-exit.active {
    background: var(--color-special-exit) !important;
}

.portal-special {
    box-shadow: 0 0 0 2px #000;
}

.portal-special::after {
    content: "KR";
    position: absolute;
    font-size: 0.8rem;
    background: #020617;
    padding: 0.16rem 0.25rem;
    border-radius: 999px;
    color: #fbbf24;
    white-space: nowrap;
    pointer-events: none;
}

/* Position icons at the end of each portal direction, aligned with the portal rotation */
.portal-ne.portal-special::after {
    top: -0.3rem;
    right: -0.8rem;
    transform: rotate(45deg);
}

.portal-se.portal-special::after {
    bottom: -0.3rem;
    right: -0.8rem;
    transform: rotate(-45deg);
}

.portal-sw.portal-special::after {
    bottom: -0.3rem;
    left: -0.8rem;
    transform: rotate(45deg);
}

.portal-nw.portal-special::after {
    top: -0.3rem;
    left: -0.8rem;
    transform: rotate(-45deg);
}

.portal-ne.portal-exit::after {
    top: 0.2rem;
    right: -2.2rem;
    transform: rotate(45deg);
}

.portal-se.portal-exit::after {
    bottom: 0.2rem;
    right: -2.2rem;
    transform: rotate(-45deg);
}

.portal-sw.portal-exit::after {
    bottom: 0.2rem;
    left: -2.2rem;
    transform: rotate(45deg);
}

.portal-nw.portal-exit::after {
    top: 0.2rem;
    left: -2.2rem;
    transform: rotate(-45deg);
}

.portal-exit {
    background: var(--color-special-exit) !important;
}

.portal-exit::after {
    content: attr(data-exit-label);
    color: #fecaca;
}

.info-panel {
    flex: 0 0 280px;
    width: 280px;
    border-radius: 0.5rem;
    border: 1px solid #374151;
    padding: 0.75rem 0.9rem;
    background: #020617;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.info-title {
    font-weight: 600;
    font-size: 0.85rem;
}

.xp-multiplier {
    font-size: 0.8rem;
    color: #fbbf24;
}

.monster-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.25rem;
    font-size: 0.75rem;
}

.monster-table th,
.monster-table td {
    padding: 0.25rem 0.3rem;
    border-bottom: 1px solid #1f2937;
    text-align: left;
}

.monster-table th {
    font-weight: 500;
    color: #9ca3af;
}

.monster-table tr:last-child td {
    border-bottom: none;
}

.monster-pill {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border-radius: 999px;
    border: 1px solid #374151;
    background: #020617;
    font-size: 0.7rem;
}

.muted {
    color: #6b7280;
}