/* ========================================================
   대항해시대 2 (Uncharted Waters 2) Web Simulator CSS
   Classic 90s KOEI Retro Maritime Theme
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;800&family=Noto+Serif+KR:wght@500;700&display=swap');

:root {
    --navy-dark: #0a1324;
    --navy-blue: #122442;
    --navy-light: #1d355e;
    --sea-blue: #26569a;
    --gold: #dfb15b;
    --gold-light: #f5e09b;
    --gold-dark: #8c6a23;
    --wood-dark: #27170c;
    --wood-mid: #4a2f1c;
    --parchment: #f6f0de;
    --parchment-border: #d4c5a0;
    --text-dark: #2c1e13;
    --text-light: #f4edd9;
    --accent-red: #c0392b;
    --accent-green: #27ae60;
    --accent-cyan: #00bcd4;
    --retro-border: 3px double #d4af37;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--navy-dark);
    font-family: 'Noto Serif KR', 'Apple SD Gothic Neo', 'Malgun Gothic', serif;
    color: var(--text-light);
}

#app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ================= Top Bar ================= */
#top-bar {
    height: 60px;
    background: linear-gradient(180deg, #1b283d 0%, #0d1624 100%);
    border-bottom: 2px solid var(--gold-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.captain-slot {
    display: flex;
    align-items: center;
    gap: 12px;
}

.captain-portrait-frame {
    width: 44px;
    height: 52px;
    border: 2px solid var(--gold);
    border-radius: 4px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.6);
    cursor: pointer;
    transition: transform 0.2s;
}

.captain-portrait-frame:hover {
    transform: scale(1.08);
    border-color: #fff;
}

.captain-portrait-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
}

.captain-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.captain-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.captain-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--gold-light);
    letter-spacing: 0.5px;
}

.nation-badge {
    font-size: 11px;
    padding: 1px 6px;
    background: #233e6b;
    border: 1px solid var(--gold-dark);
    border-radius: 3px;
    color: #fff;
}

.ship-info {
    font-size: 12px;
    color: #a8bcd8;
}

/* Center Voyage Stats */
.voyage-stats-row {
    display: flex;
    align-items: center;
    gap: 18px;
    background: rgba(8, 16, 28, 0.7);
    padding: 4px 16px;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 6px;
}

.v-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.v-stat .label {
    color: #8da4c4;
    font-size: 11px;
}

.v-stat .val {
    font-weight: 700;
    color: #f7e3af;
    font-variant-numeric: tabular-nums;
}

.v-stat .val.coords {
    color: #58d68d;
    font-family: monospace;
    font-size: 12px;
}

/* Top Right Buttons */
.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.retro-btn {
    background: linear-gradient(180deg, #374f75 0%, #1e2e47 100%);
    border: 1px solid var(--gold);
    color: var(--gold-light);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.retro-btn:hover {
    background: linear-gradient(180deg, #496899 0%, #293e61 100%);
    color: #fff;
    border-color: #fff;
    transform: translateY(-1px);
}

.retro-btn:active {
    transform: translateY(1px);
}

.retro-btn.primary {
    background: linear-gradient(180deg, #996919 0%, #613f0a 100%);
    border-color: #f5d77f;
    color: #fff;
}

.retro-btn.primary:hover {
    background: linear-gradient(180deg, #ba8225 0%, #7d5210 100%);
}

.retro-btn.glow {
    animation: btnGlow 1.4s infinite alternate;
}

.retro-select {
    background: linear-gradient(180deg, #2b3d5b 0%, #152238 100%);
    color: var(--gold-light);
    border: 1px solid var(--gold);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    outline: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
    font-family: inherit;
    transition: all 0.15s ease;
}

.retro-select:hover {
    border-color: #fff;
    color: #fff;
}

.retro-select option {
    background: #0d1624;
    color: #fff;
    padding: 4px 8px;
}

@keyframes btnGlow {
    0% { box-shadow: 0 0 5px #f1c40f; }
    100% { box-shadow: 0 0 16px #f39c12, 0 0 8px #fff; }
}

/* ================= Main Viewport Area ================= */
#main-viewport {
    flex: 1;
    position: relative;
    background: var(--sea-blue);
    overflow: hidden;
}

#canvas-sailing, #canvas-world {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#canvas-world {
    display: none;
    cursor: grab;
}

#canvas-world:active {
    cursor: grabbing;
}

/* ================= Compass & Wind HUD ================= */
#compass-widget {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, #19273c 0%, #0d1522 80%);
    border: 2px solid var(--gold);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-dial {
    position: relative;
    width: 100%;
    height: 100%;
}

.compass-cardinal {
    position: absolute;
    font-size: 11px;
    font-weight: 800;
    color: var(--gold-light);
}
.compass-cardinal.n { top: 3px; left: 50%; transform: translateX(-50%); color: #ff5757; }
.compass-cardinal.s { bottom: 3px; left: 50%; transform: translateX(-50%); }
.compass-cardinal.e { right: 5px; top: 50%; transform: translateY(-50%); }
.compass-cardinal.w { left: 5px; top: 50%; transform: translateY(-50%); }

.wind-arrow-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    transition: transform 0.4s ease-out;
}

.wind-arrow {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 24px solid #33e0ff;
    filter: drop-shadow(0 0 4px rgba(0,200,255,0.8));
}

.ship-heading-needle {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    transition: transform 0.15s ease-out;
}

.needle-pointer {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 30px solid #f1c40f;
}

.compass-center-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(13, 21, 34, 0.85);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    border: 1px solid var(--gold-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.wind-knots {
    font-size: 11px;
    font-weight: 800;
    color: #33e0ff;
}

.wind-text {
    font-size: 9px;
    color: #8fa6c7;
}

/* ================= Speed & Gauges Panel ================= */
#hud-gauges {
    position: absolute;
    bottom: 14px;
    left: 14px;
    background: linear-gradient(180deg, rgba(20, 34, 56, 0.9) 0%, rgba(9, 18, 32, 0.95) 100%);
    border: 2px solid var(--gold);
    border-radius: 8px;
    padding: 10px 14px;
    z-index: 10;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 260px;
}

.speed-meter-box {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding-bottom: 6px;
}

.speed-meter-box .label {
    font-size: 12px;
    color: #a0b6d4;
}

.speed-meter-box .value {
    font-size: 20px;
    font-weight: 800;
    color: #ffde59;
    font-family: 'Cinzel', serif;
}

.gauges-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
}

.gauge-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gauge-header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}

.gauge-header .name { color: #a9bedb; }
.gauge-header .amt { font-weight: 700; color: #fff; }

.gauge-bar-bg {
    width: 100%;
    height: 6px;
    background: #111d2e;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid #233650;
}

.gauge-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.gauge-bar-fill.durability { background: #2ecc71; }
.gauge-bar-fill.water { background: #3498db; }
.gauge-bar-fill.food { background: #e67e22; }
.gauge-bar-fill.crew { background: #9b59b6; }
.gauge-bar-fill.fatigue { background: #e74c3c; }

/* ================= Floating Interaction Prompts ================= */
#prompt-dock, #prompt-land {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, 65px);
    z-index: 15;
    display: none;
    animation: bouncePrompt 0.8s infinite alternate;
}

@keyframes bouncePrompt {
    0% { transform: translate(-50%, 65px); }
    100% { transform: translate(-50%, 75px); }
}

.prompt-btn {
    background: linear-gradient(180deg, #d35400 0%, #962d00 100%);
    border: 2px solid #f39c12;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    padding: 10px 22px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(243, 156, 18, 0.8), 0 0 10px #ffea85;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.15s;
}

.prompt-btn:hover {
    transform: scale(1.08);
}

/* ================= Bottom Quick Navigation Bar ================= */
#bottom-bar {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(11, 21, 37, 0.9);
    border: 2px solid var(--gold);
    border-radius: 30px;
    padding: 6px 14px;
    z-index: 15;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
}

.sail-level-group {
    display: flex;
    background: #0d1624;
    border-radius: 20px;
    padding: 2px;
    border: 1px solid var(--gold-dark);
}

.sail-btn {
    background: transparent;
    border: none;
    color: #9cb1ce;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.sail-btn.active {
    background: linear-gradient(180deg, #f1c40f 0%, #b78a0a 100%);
    color: #1a1200;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Minimap Radar */
#minimap-widget {
    position: absolute;
    bottom: 14px;
    right: 14px;
    width: 140px;
    height: 70px;
    background: rgba(8, 16, 28, 0.85);
    border: 2px solid var(--gold-dark);
    border-radius: 6px;
    overflow: hidden;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    cursor: pointer;
}

#canvas-minimap {
    width: 100%;
    height: 100%;
    display: block;
}

/* ================= World Map Overlay Controls ================= */
#world-controls {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 15;
    display: none;
    flex-direction: column;
    gap: 8px;
}

.world-search-box {
    position: relative;
    width: 280px;
}

.world-search-input {
    width: 100%;
    background: rgba(14, 25, 43, 0.95);
    border: 2px solid var(--gold);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

.world-search-input:focus {
    box-shadow: 0 0 10px rgba(223, 177, 91, 0.6);
}

.world-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    background: #0f1c30;
    border: 1px solid var(--gold-dark);
    border-top: none;
    border-radius: 0 0 6px 6px;
    display: none;
    z-index: 25;
}

.search-item {
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 1px solid #1a2a44;
    display: flex;
    justify-content: space-between;
}

.search-item:hover {
    background: #1e355c;
    color: var(--gold-light);
}

.world-legend {
    background: rgba(12, 22, 38, 0.9);
    border: 1px solid var(--gold-dark);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #a8bedd;
}

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

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid #000;
}
.legend-dot.port { background: #ffdd33; }
.legend-dot.supply { background: #ffffff; }
.legend-dot.disc { background: #ff3355; border-radius: 2px; }
.legend-dot.fleet { background: #33e0ff; }

/* ================= MODAL DIALOGS ================= */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.retro-dialog {
    background: var(--parchment);
    color: var(--text-dark);
    border: 4px ridge #c29b38;
    border-radius: 6px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.8), inset 0 0 15px rgba(184, 150, 87, 0.3);
    max-width: 720px;
    width: 92%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.dialog-header {
    background: linear-gradient(180deg, #3d2314 0%, #201109 100%);
    border-bottom: 2px solid var(--gold);
    color: var(--gold-light);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dialog-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dialog-close {
    background: transparent;
    border: none;
    color: #e2c079;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
}

.dialog-close:hover {
    color: #fff;
}

.dialog-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

/* Port Tabs */
.port-tabs {
    display: flex;
    background: #e2d7be;
    border-bottom: 2px solid #b39f77;
    overflow-x: auto;
}

.port-tab-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    font-size: 13px;
    font-weight: 700;
    color: #4b3620;
    cursor: pointer;
    border-right: 1px solid #cbbe9f;
    white-space: nowrap;
    transition: background 0.15s;
}

.port-tab-btn:hover {
    background: #f1ebd8;
}

.port-tab-btn.active {
    background: var(--parchment);
    color: #8b2b10;
    border-top: 3px solid #8b2b10;
}

/* Port Tab Contents */
.tab-content {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.tab-content.active {
    display: flex;
}

.port-hero-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #e9dfc7;
    border: 1px solid var(--parchment-border);
    padding: 10px 14px;
    border-radius: 4px;
}

.port-stats-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.p-stat-box {
    background: #fff;
    border: 1px solid #dcd1b6;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
}

.p-stat-box .title { color: #6d5b47; }
.p-stat-box .val { font-weight: 700; color: #1e2e47; }

/* Market Trading Table */
.trade-table-container {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #d4c5a0;
    border-radius: 4px;
    background: #fff;
}

.trade-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.trade-table th, .trade-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #ede4d1;
    text-align: left;
}

.trade-table th {
    background: #f2ebda;
    color: #4b3620;
    font-weight: 700;
    position: sticky;
    top: 0;
}

.trade-action-btn {
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #a68434;
    background: #f39c12;
    color: #fff;
    border-radius: 3px;
    cursor: pointer;
}

.trade-action-btn:hover {
    background: #e67e22;
}

/* Discovery Modal */
.discovery-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
    padding: 10px 0;
}

.discovery-badge {
    display: inline-block;
    background: #c0392b;
    color: #fff;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
}

.discovery-title {
    font-size: 26px;
    font-weight: 800;
    color: #63260c;
}

.discovery-rewards {
    display: flex;
    gap: 20px;
    background: #eee3ca;
    padding: 8px 24px;
    border-radius: 6px;
    border: 1px solid #d9cbab;
}

.discovery-lore {
    font-size: 14px;
    line-height: 1.7;
    color: #3b2816;
    max-width: 540px;
    background: #fff;
    padding: 14px 18px;
    border: 1px solid #ded3ba;
    border-radius: 4px;
    white-space: pre-line;
}

/* Hero Select Modal */
.heroes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.hero-card {
    background: #fff;
    border: 2px solid #cebea0;
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.hero-card:hover {
    border-color: #a3721c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.hero-card.active {
    border-color: #8b2b10;
    background: #fdfaf2;
    box-shadow: 0 0 0 2px #8b2b10;
}

.hero-portrait {
    width: 64px;
    height: 80px;
    border: 2px solid #8b6b29;
    border-radius: 4px;
    image-rendering: pixelated;
}

.hero-name {
    font-weight: 700;
    font-size: 14px;
    color: #412610;
}

.hero-nation {
    font-size: 11px;
    color: #7a634a;
}

.hero-motto {
    font-size: 11px;
    color: #884422;
    margin-top: 4px;
    line-height: 1.3;
}

/* Responsive Touch Controls for Mobile/Tablet */
#touch-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: none;
    justify-content: space-between;
    pointer-events: none;
    z-index: 15;
}

.touch-btn {
    pointer-events: auto;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(18, 36, 66, 0.85);
    border: 2px solid var(--gold);
    color: var(--gold-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

@media (max-width: 800px) {
    #touch-controls { display: flex; }
    .voyage-stats-row { display: none; }
    #compass-widget { width: 90px; height: 90px; }
    .heroes-grid { grid-template-columns: repeat(2, 1fr); }
}
