* {
    box-sizing: border-box;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #1a1a2e;
    color: #ecf0f1;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    user-select: none;
    -webkit-user-select: none;
}

h1 {
    margin-bottom: 5px;
    color: #ecf0f1;
    text-align: center;
}

.title-gold {
    color: #f1c40f;
}

.subtitle {
    color: #a9a9a9;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.subtitle-home {
    font-weight: normal;
    font-size: 16px;
}

.hidden {
    display: none !important;
}

.spacer {
    width: 20px;
}

#btn-global-home {
    position: fixed;
    top: 20px;
    left: 20px;
    background: #a569bd;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
}

#btn-global-home:hover {
    background: #bb8fce;
    transform: translateY(-2px);
}

#btn-global-repo {
    position: fixed;
    top: 20px;
    left: 138px;
    background: #52687a;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    z-index: 9999;
}

#btn-global-repo:hover {
    background: #5f7688;
    transform: translateY(-2px);
}

#btn-global-hint {
    position: fixed;
    top: 20px;
    right: 150px;
    background: #f39c12;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    z-index: 9999;
}

#btn-global-hint:hover {
    background: #f1c40f;
    transform: translateY(-2px);
}

#btn-global-reset {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #c0392b;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    z-index: 9999;
}

#btn-global-reset:hover {
    background: #e74c3c;
    transform: translateY(-2px);
}

.view-container {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 60px;
}

.view-container.active {
    display: flex;
}

.top-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.control-btn {
    background: #2980b9;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: 0.2s;
}

.control-btn:hover {
    background: #3498db;
}

.control-btn:disabled {
    background: #34495e;
    cursor: not-allowed;
    color: #7f8c8d;
}

.btn-red {
    background: #c0392b;
}

.btn-red:hover {
    background: #e74c3c;
}

.btn-orange {
    background: #e67e22;
}

.btn-orange:hover {
    background: #f39c12;
}

.btn-green {
    background: #27ae60;
}

.btn-green:hover {
    background: #2ecc71;
}

.btn-purple {
    background: #8e44ad;
}

.btn-purple:hover {
    background: #9b59b6;
}

.btn-gold {
    background: #f39c12;
}

.btn-gold:hover {
    background: #f1c40f;
}

.ui-panel {
    margin: 20px auto 0 auto;
    text-align: left;
    background: #16213e;
    padding: 15px 25px;
    border-radius: 10px;
    width: 100%;
    max-width: 600px;
    box-sizing: border-box;
}

.playtest-library {
    width: 100%;
    max-width: 620px;
    background: #16213e;
    border-radius: 12px;
    padding: 20px;
    margin-top: 15px;
    box-sizing: border-box;
}

.gallery-accordion {
    margin-bottom: 20px;
    border-bottom: 1px solid #2c3e50;
    padding-bottom: 10px;
    min-width: 0;
    width: 100%;
}
.gallery-accordion:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.gallery-accordion summary {
    font-size: 16px;
    font-weight: bold;
    color: #f1c40f;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    user-select: none;
}
.gallery-accordion summary::-webkit-details-marker { display: none; }
.gallery-accordion summary i {
    font-style: normal;
    transition: transform 0.2s;
    font-size: 10px;
}
.gallery-accordion[open] summary i { transform: rotate(90deg); }
.accordion-content { margin-top: 15px; }

.gallery-accordion .tile-list,
.gallery-accordion .saved-tiles-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
    width: 100%;
}

.wide-panel {
    max-width: 850px;
}

.instructions {
    font-size: 14px;
    color: #a9a9a9;
    line-height: 1.6;
}

#home-view {
    margin-top: 5vh;
    gap: 30px;
}

.home-title {
    font-size: 64px;
    text-shadow: 0 0 20px rgba(241, 196, 15, 0.4);
    margin: 0;
}

.home-card-container {
    display: flex;
    gap: 30px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 900px;
}

.home-card {
    background: #16213e;
    padding: 30px 20px;
    border-radius: 15px;
    width: 220px;
    text-align: center;
    border: 2px solid #2980b9;
    cursor: pointer;
    transition: 0.3s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.home-card:hover {
    transform: translateY(-10px);
    border-color: #f1c40f;
    box-shadow: 0 15px 40px rgba(241, 196, 15, 0.2);
}

.home-card h2 {
    color: #f1c40f;
    margin-top: 0;
    font-size: 20px;
}

.home-card p {
    font-size: 14px;
    margin-bottom: 0;
    color: #a9a9a9;
}

.repo-list {
    width: 100%;
    max-width: 850px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
}

.repo-item {
    background: #16213e;
    padding: 15px 25px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid #2c3e50;
}

.repo-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
    border-bottom: 1px solid #2c3e50;
    padding-bottom: 10px;
}

.repo-item-title {
    font-weight: bold;
    color: #f1c40f;
    font-size: 18px;
    flex: 1 1 auto;
    min-width: 0;
}

.repo-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-left: auto;
    flex: 0 0 auto;
}

.repo-routes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.route-chip {
    background: #2980b9;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-weight: bold;
    border: none;
    transition: 0.2s;
    text-align: left;
}

.route-chip:hover {
    background: #3498db;
}

.route-chip.solution {
    background: #27ae60;
}

.route-chip.solution:hover {
    background: #2ecc71;
}

.repo-solutions details {
    background: #0f172a;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #2c3e50;
}

.repo-solutions summary {
    color: #ecf0f1;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}

.repo-solutions summary::-webkit-details-marker {
    display: none;
}

.repo-solutions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.classic-game-area {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    width: 100%;
    flex-wrap: wrap;
    user-select: none;
}

.side-inventory {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 110px;
    align-items: center;
    position: relative;
}

.main-board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 620px;
    min-width: 0;
}

.board-panel {
    width: 100%;
    max-width: 620px;
    background-color: #16213e;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.hex-board {
    width: 100%;
    height: min(580px, 78vw, 68dvh);
    flex-shrink: 0;
    touch-action: none;
    background-color: #16213e;
    display: block;
}

.hex-bg {
    transition: fill 0.2s, stroke 0.2s;
}

.hex-playable {
    fill: #ecf0f1;
    stroke: #bdc3c7;
    stroke-width: 2;
    cursor: pointer;
    transition: fill 0.2s;
}

.hex-playable:hover {
    fill: #d5dbdb;
}

.hex-removed {
    fill: #16213e;
    stroke: #bdc3c7;
    stroke-width: 2;
    cursor: pointer;
}

.hex-removed:hover {
    fill: #1d2b4a;
}

.hex-locked,
.hex-fixed {
    stroke-width: 2;
}

.hex-locked:hover,
.hex-fixed:hover {
    fill: #d5dbdb;
}

.hex-boundary {
    fill: #34495e;
    stroke: #2c3e50;
    stroke-width: 2;
}

.hex-boundary.unusable-boundary {
    fill: #2b3a4d;
    stroke: #233140;
}

.boundary-text {
    fill: #f1c40f;
    font-size: 20px;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.boundary-text.unusable-boundary-text {
    fill: rgba(241, 196, 15, 0.35);
}

.cell-wall-edge {
    pointer-events: none;
}

.editor-wall-hit {
    cursor: pointer;
    pointer-events: all;
}

.path-outline,
.path-fill {
    fill: none;
    stroke-linecap: butt;
    pointer-events: none;
    transition: stroke 0.4s, stroke-width 0.4s;
}

.tile-btn {
    background: #0f3460;
    border: 3px solid transparent;
    border-radius: 8px;
    cursor: grab;
    transition: 0.2s;
    width: clamp(72px, 18vw, 100px);
    height: clamp(72px, 18vw, 100px);
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    box-sizing: border-box;
}

.tile-btn:active {
    cursor: grabbing;
}

.tile-btn:hover {
    background: #1a4a82;
    border-color: #3498db;
}

.trash-bin {
    width: calc(100% - 24px);
    margin: 8px 12px 12px 12px;
    min-height: 60px;
    border-radius: 10px;
    background: rgba(231, 76, 60, 0.1);
    border: 2px dashed #e74c3c;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e74c3c;
    font-weight: bold;
    font-size: 16px;
    line-height: 1.35;
    text-align: center;
    padding: 10px 12px;
    transition: all 0.3s;
}

.trash-bin.drag-over {
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border-style: solid;
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

.trash-icon {
    font-size: 20px;
    margin-right: 10px;
}

#win-screen {
    position: absolute;
    inset: 0;
    background: rgba(22, 33, 62, 0.85);
    backdrop-filter: blur(4px);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease-in-out;
    z-index: 100;
}

#win-screen.show {
    opacity: 1;
    pointer-events: all;
}

.win-box {
    background: rgba(26, 26, 46, 0.95);
    padding: 35px 40px;
    border-radius: 15px;
    text-align: center;
    border: 2px solid #f1c40f;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    width: min(calc(100% - 24px), 460px);
}

.win-title {
    font-size: 42px;
    color: #f1c40f;
    text-shadow: 0 0 20px rgba(241, 196, 15, 0.5);
    margin: 0 0 10px 0;
}

.win-subtitle {
    color: #ecf0f1;
    font-size: 18px;
    margin-bottom: 25px;
}

.win-duplicate-note {
    color: #ff7675;
    font-size: 15px;
    font-weight: 700;
    margin: -10px 0 25px 0;
}

.win-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.editor-area {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

.side-panel {
    background: #16213e;
    padding: 15px;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    margin: 0;
    align-items: center;
    position: relative;
}

.side-panel-editor {
    width: 196px;
    height: 680px;
}

.panel-title {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: #bdc3c7;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    width: 100%;
    border-bottom: 1px solid #34495e;
    padding-bottom: 8px;
}

.config-panel {
    background: #16213e;
    padding: 15px 30px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid #2980b9;
    width: 100%;
    max-width: 850px;
    box-sizing: border-box;
}

.compact-config {
    max-width: 650px;
    padding: 10px 20px;
}

.config-row {
    display: flex;
    gap: 20px;
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
    align-items: center;
}

.config-group {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
}

select,
input[type="text"] {
    background: #0f3460;
    color: white;
    border: 1px solid #3498db;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 14px;
}

input[type="text"] {
    font-weight: bold;
    width: 180px;
    text-align: center;
}

select:focus,
input:focus {
    outline: none;
    border-color: #f1c40f;
}

.board-wrapper {
    width: 100%;
    max-width: 600px;
    height: auto;
    flex-shrink: 0;
    background-color: #0f172a;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.board-wrapper-editor {
    max-width: 600px;
}

.editor-board {
    height: min(600px, 78vw, 70dvh);
}

.palette-letters {
    display: grid;
    grid-template-columns: repeat(3, 44px);
    gap: 8px;
    justify-content: center;
    overflow-y: auto;
    padding-right: 0;
    align-content: flex-start;
    flex-grow: 1;
    width: 100%;
}

.palette-letters::-webkit-scrollbar {
    width: 4px;
}

.palette-letters::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 10px;
}

.letter-node {
    width: 44px;
    height: 50px;
    cursor: grab;
    position: relative;
    touch-action: none;
}

.letter-node svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.triangle-letter-node {
    width: 40px;
    height: 44px;
    overflow: hidden;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.triangle-letter-node svg {
    width: 40px;
    height: 40px;
    overflow: hidden;
}

.letter-node polygon {
    fill: #34495e;
    stroke: #f1c40f;
    stroke-width: 2;
    transition: 0.2s;
}

.letter-node text {
    fill: #f1c40f;
    font-size: 20px;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: central;
}

.letter-node:active {
    cursor: grabbing;
    transform: scale(1.08);
}

.letter-node:hover polygon {
    fill: #0f3460;
    stroke: #fff;
}

.letter-node:hover text {
    fill: #fff;
}

.letter-node.faded {
    opacity: 0.35;
}

.editor-palette-disabled {
    opacity: 0.45;
}

.control-btn.active {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.75);
}

.control-btn.tool-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.editor-rotation-limit-select {
    min-width: 118px;
    font-weight: 700;
}

.editor-grid-warning {
    width: 100%;
    max-width: 760px;
    margin: -4px 0 0 0;
    color: #ff7675;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

.cell-lock-icon {
    fill: #2874a6;
    font-size: 18px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.cell-rotation-limit-badge {
    fill: rgba(15, 52, 96, 0.88);
    stroke: #5dade2;
    stroke-width: 1.2;
    pointer-events: none;
}

.cell-rotation-limit-text {
    fill: #d6eaf8;
    font-size: 8px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.editor-fixed-card.selected {
    border-color: #f1c40f;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.4);
}

.editor-fixed-card:hover .mini-path-outline,
.editor-fixed-card.selected .mini-path-outline {
    stroke: #8b0000;
}

.editor-fixed-card:hover .mini-path,
.editor-fixed-card.selected .mini-path {
    stroke: #e74c3c;
}

#tile-editor-board {
    background: #0f172a;
    border-radius: 15px;
    border: 2px solid #2980b9;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    cursor: crosshair;
    touch-action: none;
}

#tile-base-poly {
    fill: #16213e;
    stroke: #3498db;
    stroke-width: 4;
}

.forge-edge-node {
    fill: #3498db;
    stroke: #fff;
    stroke-width: 3;
    cursor: pointer;
    transition: 0.2s;
    touch-action: none;
}

.forge-edge-node:hover {
    fill: #f1c40f;
    stroke: #e74c3c;
    stroke-width: 5;
}

.forge-edge-node.selected {
    fill: #e74c3c;
    stroke: #f1c40f;
    stroke-width: 4;
}

.forge-path-hitbox {
    fill: none;
    stroke: transparent;
    stroke-width: 35;
    cursor: pointer;
}

.forge-path-fill {
    fill: none;
    stroke: #e74c3c;
    stroke-width: 10;
    pointer-events: none;
    transition: stroke 0.2s;
}

.forge-path-outline {
    fill: none;
    stroke: #8b0000;
    stroke-width: 18;
    pointer-events: none;
    transition: stroke 0.2s;
}

.forge-path-group:hover .forge-path-fill {
    stroke: #f39c12;
}

.forge-path-group.selected .forge-path-fill {
    stroke: #f1c40f;
}

.forge-path-group.selected .forge-path-outline {
    stroke: #e67e22;
}

.saved-title {
    margin-top: 40px;
    margin-bottom: 5px;
}

.saved-subtitle {
    font-size: 13px;
    color: #a9a9a9;
    text-align: center;
    margin-top: 0;
}

.saved-tiles-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.tile-category-container {
    margin-top: 25px;
    width: 100%;
    max-width: 800px;
    text-align: left;
}

.tile-category-title {
    color: #f1c40f;
    border-bottom: 1px solid #34495e;
    padding-bottom: 5px;
    margin-bottom: 15px;
    font-size: 20px;
}

.tile-list {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.saved-tile-card {
    background: #16213e;
    border: 2px solid #34495e;
    border-radius: 10px;
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: 0.2s;
    position: relative;
    touch-action: none;
}

.saved-tile-card:hover {
    border-color: #3498db;
    background: #1a2a4e;
    transform: translateY(-3px);
}

.saved-tile-card.selected {
    border-color: #f1c40f;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.4);
}

.saved-tile-card .mini-path {
    stroke: #3498db;
    transition: stroke 0.2s;
}

.saved-tile-card:hover .mini-path {
    stroke: #e74c3c;
}

.new-tile-btn {
    background: #0f172a;
    border: 2px dashed #7f8c8d;
    color: #7f8c8d;
    font-size: 24px;
    font-weight: bold;
}

.new-tile-btn:hover {
    border-color: #f1c40f;
    color: #f1c40f;
    background: #16213e;
}

.gallery-trash {
    background: rgba(231, 76, 60, 0.1);
    border: 2px dashed #e74c3c;
    color: #e74c3c;
    font-size: 24px;
    transition: all 0.3s;
}

.gallery-trash.drag-over {
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border-style: solid;
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.5);
    transform: scale(1.05);
}

#toast {
    position: fixed;
    top: 20px;
    background: #e74c3c;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 1000;
}

#global-drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

#global-drag-ghost.ghost-box-mode {
    width: 110px;
    height: 110px;
    background: #0f3460;
    border: 3px solid #f1c40f;
    border-radius: 8px;
    margin-left: -55px;
    margin-top: -55px;
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.5);
}

#global-drag-ghost.ghost-shape-mode {
    width: 115px;
    height: 115px;
    background: transparent;
    border: none;
    box-shadow: none;
    margin-left: -57px;
    margin-top: -57px;
}

#global-drag-ghost svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

#ghost-letter {
    fill: #f1c40f;
    font-size: 26px;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: central;
}

@media (max-width: 1100px) {

    .classic-game-area,
    .editor-area {
        flex-direction: column;
        align-items: center;
    }

    .side-inventory {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    .board-panel,
    .board-wrapper {
        width: 100%;
    }

    .hex-board {
        width: 100%;
    }

    .board-width-panel {
        max-width: 100%;
    }

    .side-panel-editor {
        width: 100%;
        max-width: 600px;
        height: auto;
        min-height: 0;
    }
}


.btn-grey {
    background: #34495e;
}

.btn-grey:hover {
    background: #4a6072;
}

.btn-home-global {
    background: #a569bd;
}

.btn-home-global:hover {
    background: #bb8fce;
}

.board-width-panel {
    max-width: 620px;
}

.inventory-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.inventory-shell.classic-shell {
    min-width: 110px;
}

.inventory-shell.playtest-shell {
    background: #16213e;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    width: 140px;
    height: 670px;
    position: relative;
}

.side-inventory {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 110px;
    align-items: center;
}

.inventory-shell.playtest-shell .side-inventory {
    width: 100%;
    flex-grow: 1;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 5px 0;
    border: 2px solid transparent;
    border-radius: 10px;
    gap: 12px;
}

.inventory-shell.playtest-shell .side-inventory::-webkit-scrollbar {
    width: 4px;
}

.inventory-shell.playtest-shell .side-inventory::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 10px;
}

.inventory-shell.playtest-shell .tile-btn {
    width: clamp(68px, 16vw, 90px);
    height: clamp(68px, 16vw, 90px);
}

.inventory-shell.classic-shell .tile-btn {
    width: clamp(72px, 18vw, 100px);
    height: clamp(72px, 18vw, 100px);
}

.palette-add-btn {
    background: #0f172a;
    border: 2px dashed #7f8c8d;
    color: #7f8c8d;
    border-radius: 8px;
    width: clamp(68px, 16vw, 90px);
    height: clamp(68px, 16vw, 90px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    margin-top: 12px;
    flex-shrink: 0;
}

.palette-add-btn:hover {
    border-color: #f1c40f;
    color: #f1c40f;
    background: #16213e;
}

.palette-trash {
    width: clamp(68px, 16vw, 90px);
    height: 50px;
    border-radius: 8px;
    background: rgba(231, 76, 60, 0.1);
    border: 2px dashed #e74c3c;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e74c3c;
    font-size: 20px;
    transition: all 0.3s;
    flex-shrink: 0;
    margin-top: 10px;
}

.palette-trash.drag-over {
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border-style: solid;
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.5);
}

.playtest-library {
    width: 100%;
    max-width: 620px;
    margin-top: 26px;
}

.playtest-library-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    flex-wrap: wrap;
}

.section-title-inline {
    margin-top: 0;
}

.section-subtitle-inline {
    text-align: left;
    margin-bottom: 0;
}

.repo-solution-link {
    color: #2ecc71;
    cursor: pointer;
    font-weight: 600;
    padding: 2px 0;
}

.repo-solution-link:hover {
    color: #58d68d;
}

.repo-solutions summary {
    color: #2ecc71;
    list-style: revert;
}

.repo-solutions summary::-webkit-details-marker {
    display: inline;
}

.palette-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.palette-modal.show {
    display: flex;
}

.modal-content {
    background: #16213e;
    padding: 25px;
    border-radius: 15px;
    border: 2px solid #3498db;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 80px));
    gap: 15px;
    justify-content: center;
    justify-items: center;
    margin-top: 20px;
}

.hint-modal-content {
    max-width: 640px;
    text-align: left;
}

.hint-summary {
    color: #ecf0f1;
    font-size: 16px;
    line-height: 1.5;
    margin: 0 0 18px 0;
}

.hint-issues {
    margin: 0;
    padding-left: 22px;
    color: #dfe6e9;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hint-issues li {
    line-height: 1.5;
}

#global-drag-ghost.ghost-box-mode {
    width: 110px;
    height: 110px;
}

#global-drag-ghost.ghost-shape-mode {
    width: 115px;
    height: 115px;
    margin-left: -57px;
    margin-top: -57px;
}

#global-drag-ghost.ghost-gallery-mode {
    width: 80px;
    height: 80px;
    margin-left: -40px;
    margin-top: -40px;
    background: #16213e;
    border: 2px solid #f1c40f;
    border-radius: 10px;
    box-shadow: 0 0 22px rgba(241, 196, 15, 0.6);
}

.drop-indicator {
    width: 90px;
    height: 4px;
    background: #f1c40f;
    border: none;
    border-radius: 999px;
    box-sizing: border-box;
    transition: 0.2s;
    pointer-events: none;
    box-shadow: 0 0 12px rgba(241, 196, 15, 0.45);
}

.drop-indicator-overlay {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.drop-indicator-line {
    height: 4px;
}

.drop-indicator-box {
    width: 90px;
    height: 90px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed #f1c40f;
    border-radius: 10px;
    box-shadow: none;
}

polygon.endpoint-highlight {
    fill: rgba(241, 196, 15, 0.3);
    stroke: #f1c40f;
    stroke-width: 3px;
    transition: all 0.2s;
}

.repo-solution-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.repo-solution-row .control-btn {
    padding: 4px 8px;
    font-size: 12px;
    flex-shrink: 0;
}

@media (max-width: 1100px) {
    .inventory-shell.playtest-shell {
        width: 100%;
        max-width: 620px;
        height: auto;
    }

    .inventory-shell.playtest-shell .side-inventory {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        max-height: none;
    }

    .playtest-library-header {
        align-items: center;
    }

    .board-width-panel {
        max-width: 100%;
    }
}

.repo-solutions-summary {
    color: #2ecc71;
    font-weight: 700;
}

.repo-solution-tab {
    background: rgba(46, 204, 113, 0.14);
    color: #2ecc71;
    border: 1px solid #27ae60;
    border-radius: 8px;
    padding: 8px 12px;
    text-align: left;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}

.repo-solution-tab:hover {
    background: rgba(46, 204, 113, 0.22);
    color: #58d68d;
}

#game-view.solution-view-only .classic-game-area {
    justify-content: center;
}

#game-view.solution-view-only .main-board-container {
    width: 100%;
    max-width: 620px;
}

@media (max-width: 700px) {
    body {
        padding: calc(96px + env(safe-area-inset-top)) 12px calc(18px + env(safe-area-inset-bottom));
    }

    .home-title {
        font-size: clamp(40px, 15vw, 64px);
    }

    .subtitle {
        font-size: 16px;
    }

    .control-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    #btn-global-home,
    #btn-global-repo,
    #btn-global-hint,
    #btn-global-reset {
        padding: 8px 12px;
        font-size: 13px;
    }

    #btn-global-home {
        top: calc(12px + env(safe-area-inset-top));
        left: 12px;
    }

    #btn-global-repo {
        top: calc(54px + env(safe-area-inset-top));
        left: 12px;
    }

    #btn-global-hint {
        top: calc(12px + env(safe-area-inset-top));
        right: 12px;
    }

    #btn-global-reset {
        top: calc(54px + env(safe-area-inset-top));
        right: 12px;
    }

    .board-panel,
    .board-wrapper,
    .playtest-library,
    .ui-panel,
    .config-panel {
        border-radius: 12px;
    }

    .hex-board {
        height: min(580px, 84vw, 56dvh);
    }

    .editor-board {
        height: min(600px, 84vw, 58dvh);
    }

    .trash-bin {
        font-size: 12px;
        min-height: 54px;
    }

    .trash-icon {
        font-size: 18px;
        margin-right: 6px;
    }

    .win-box {
        width: calc(100% - 20px);
        padding: 24px 18px;
    }

    .win-title {
        font-size: clamp(28px, 8vw, 42px);
    }

    .modal-content {
        width: 100%;
        padding: 18px;
        max-height: 85dvh;
    }

    .modal-grid {
        gap: 12px;
    }
}
