:root {
  --ink: #17324a;
  --ink-soft: #36526a;
  --cream: #fff8df;
  --paper: #fffdf4;
  --grass: #8fca75;
  --grass-dark: #4e8a59;
  --sky: #9bd8e8;
  --coral: #ef7e68;
  --yellow: #f6ca62;
  --teal: #49a9a5;
  --danger: #c95050;
  --line: rgba(23, 50, 74, 0.16);
  --shadow: 0 18px 48px rgba(23, 50, 74, 0.2);
  font-family: Inter, ui-rounded, "Trebuchet MS", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #dff3ea;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { overflow-x: hidden; background: radial-gradient(circle at top, #f8f1c9 0, #dff3ea 42%, #b8dbc4 100%); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }

.app-shell { min-height: 100vh; min-height: 100dvh; }
.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen--active { display: flex; }

.loading-screen { align-items: center; justify-content: center; padding: 24px; background: linear-gradient(160deg, #7fc7d7, #f8d77d 70%, #84bd72); }
.loading-card { width: min(480px, 100%); padding: 44px 34px; border: 4px solid var(--ink); border-radius: 34px; background: rgba(255, 253, 244, 0.92); box-shadow: var(--shadow); text-align: center; }
.brand-mark { width: 86px; height: 86px; display: grid; place-items: center; margin: 0 auto 18px; border: 4px solid var(--ink); border-radius: 28px; background: var(--yellow); font-size: 46px; transform: rotate(-4deg); }
.eyebrow { margin: 0 0 8px; font-size: 0.76rem; font-weight: 900; letter-spacing: 0.16em; color: var(--teal); }
h1, h2, h3, p { margin-top: 0; }
.loading-card h1, .menu-card h1 { margin-bottom: 0; font-size: clamp(2.5rem, 9vw, 5.6rem); line-height: 0.9; letter-spacing: -0.065em; text-transform: uppercase; }
.subtitle { margin: 8px 0 24px; font-weight: 800; color: var(--coral); }
.loading-track { height: 18px; overflow: hidden; border: 3px solid var(--ink); border-radius: 999px; background: #e6ead8; }
.loading-track span { display: block; width: 0%; height: 100%; background: repeating-linear-gradient(135deg, var(--teal) 0 12px, #7bc8bf 12px 24px); transition: width 180ms ease; }
.loading-text { margin: 14px 0 0; font-weight: 800; }

.menu-screen { position: relative; align-items: center; justify-content: center; overflow: hidden; padding: 28px; background: linear-gradient(#83cde2 0 48%, #9bd47f 48% 100%); }
.menu-art { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.sun { position: absolute; width: 170px; height: 170px; right: 8%; top: 8%; border: 5px solid var(--ink); border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 24px rgba(246, 202, 98, .25); }
.hill { position: absolute; bottom: -24%; border: 5px solid var(--ink); border-radius: 50%; background: #6eae68; }
.hill--one { width: 70%; height: 54%; left: -12%; }
.hill--two { width: 76%; height: 60%; right: -19%; background: #82bf6c; }
.menu-bug, .menu-plant { position: absolute; filter: drop-shadow(0 6px 0 rgba(23,50,74,.14)); }
.bug--one { left: 6%; bottom: 15%; font-size: 56px; transform: rotate(-10deg); }
.bug--two { right: 7%; bottom: 14%; font-size: 70px; transform: rotate(8deg); }
.menu-plant { left: 18%; top: 13%; font-size: 74px; }
.menu-card { position: relative; z-index: 1; width: min(620px, 100%); padding: clamp(26px, 5vw, 48px); border: 4px solid var(--ink); border-radius: 36px; background: rgba(255, 253, 244, .94); box-shadow: var(--shadow); text-align: center; }
.menu-description { max-width: 480px; margin: 0 auto 22px; color: var(--ink-soft); font-weight: 650; line-height: 1.6; }
.record-strip { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 auto 22px; padding: 13px 18px; border: 3px solid var(--ink); border-radius: 18px; background: #edf7de; font-weight: 800; }
.record-strip strong { font-size: 1.3rem; }
.menu-actions { display: grid; gap: 11px; }

.button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; padding: 12px 20px; border: 3px solid var(--ink); border-radius: 16px; background: var(--paper); box-shadow: 0 5px 0 var(--ink); font-weight: 900; text-decoration: none; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, filter .12s ease; }
.button:hover { filter: brightness(1.03); transform: translateY(-1px); }
.button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.button--primary { background: var(--yellow); }
.button--secondary { background: #b9e2d5; }
.button--ghost { background: #edf1ee; }
.button--danger { background: #f1a5a0; }
.button--link { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; text-underline-offset: 4px; }
.button--wide { width: 100%; }
.button:disabled { opacity: .48; cursor: not-allowed; transform: none; box-shadow: 0 5px 0 var(--ink); }

.game-screen { display: none; flex-direction: column; background: #d8efe0; }
.game-screen.screen--active { display: flex; }
.game-header { position: sticky; top: 0; z-index: 20; min-height: 68px; display: flex; align-items: center; gap: 12px; padding: 10px max(14px, env(safe-area-inset-left)) 10px max(14px, env(safe-area-inset-right)); border-bottom: 3px solid var(--ink); background: rgba(255, 253, 244, .96); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.game-brand { display: flex; align-items: center; gap: 8px; margin-right: auto; font-size: 1.05rem; }
.game-brand span { font-size: 1.6rem; }
.stat { min-width: 76px; display: grid; gap: 1px; padding: 6px 10px; border: 2px solid var(--line); border-radius: 13px; background: #fff; }
.stat span { font-size: .68rem; font-weight: 800; color: var(--ink-soft); }
.stat strong { font-size: 1rem; }
.header-actions { display: flex; gap: 8px; }
.icon-button { width: 46px; height: 46px; border: 3px solid var(--ink); border-radius: 14px; background: var(--yellow); box-shadow: 0 4px 0 var(--ink); font-weight: 900; cursor: pointer; }
.icon-button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.game-layout { width: min(1480px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; margin: 0 auto; padding: 18px; }
.board-column { min-width: 0; }
.message-banner { min-height: 40px; display: grid; place-items: center; margin-bottom: 10px; padding: 8px 14px; border: 3px solid var(--ink); border-radius: 14px; background: var(--cream); font-weight: 850; text-align: center; }
.message-banner--warning { background: #ffd0c8; }
.message-banner--success { background: #d7efbd; }
.canvas-frame { overflow: hidden; border: 4px solid var(--ink); border-radius: 24px; background: #8fc777; box-shadow: var(--shadow); }
canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.mobile-selection { display: none; margin-top: 8px; padding: 8px 12px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); font-size: .82rem; font-weight: 800; text-align: center; }
.tower-shop { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.tower-card { min-width: 0; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 9px; padding: 10px; border: 3px solid var(--ink); border-radius: 17px; background: var(--paper); box-shadow: 0 5px 0 var(--ink); text-align: left; cursor: pointer; }
.tower-card:hover { background: #fff5c9; }
.tower-card:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.tower-card--selected { outline: 5px solid rgba(73,169,165,.35); background: #d8f1e8; }
.tower-card--locked { opacity: .55; }
.tower-icon { font-size: 1.8rem; }
.tower-copy { min-width: 0; display: grid; }
.tower-copy strong { overflow: hidden; font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.tower-copy small { overflow: hidden; color: var(--ink-soft); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.tower-price { min-width: 34px; padding: 4px 6px; border-radius: 9px; background: var(--yellow); font-size: .8rem; font-weight: 900; text-align: center; }
.tower-price::before { content: "🪙 "; font-size: .7rem; }

.side-panel { display: flex; flex-direction: column; gap: 13px; }
.panel-card { padding: 18px; border: 3px solid var(--ink); border-radius: 20px; background: var(--paper); box-shadow: 0 6px 0 var(--ink); }
.panel-card h2 { margin-bottom: 8px; font-size: 1.2rem; }
.panel-card p { color: var(--ink-soft); line-height: 1.45; }
.panel-label { margin-bottom: 8px !important; color: var(--teal) !important; font-size: .72rem; font-weight: 950; letter-spacing: .13em; }
.selected-title { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.selected-title > span { width: 54px; height: 54px; display: grid; place-items: center; border: 3px solid var(--ink); border-radius: 16px; background: var(--yellow); font-size: 2rem; }
.selected-title h2, .selected-title p { margin: 0; }
.tower-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 14px; }
.tower-stats div { padding: 9px; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
.tower-stats dt { font-size: .7rem; font-weight: 800; color: var(--ink-soft); }
.tower-stats dd { margin: 2px 0 0; font-weight: 950; }
.tower-panel .button + .button { margin-top: 9px; }
.tip-card { margin-top: auto; background: #e7f5ce; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 22px; background: rgba(14, 35, 49, .68); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.modal-backdrop[hidden], .modal[hidden] { display: none; }
.modal { position: relative; width: min(780px, 100%); max-height: min(90vh, 760px); overflow: auto; padding: clamp(24px, 5vw, 42px); border: 4px solid var(--ink); border-radius: 28px; background: var(--paper); box-shadow: var(--shadow); }
.modal--small { width: min(460px, 100%); }
.modal h2 { font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 42px; height: 42px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; font-size: 1.5rem; font-weight: 900; cursor: pointer; }
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.guide-grid article { padding: 16px; border: 2px solid var(--line); border-radius: 16px; background: #fff; }
.guide-grid article > span { width: 34px; height: 34px; display: grid; place-items: center; margin-bottom: 10px; border-radius: 50%; background: var(--yellow); font-weight: 950; }
.guide-grid h3 { margin-bottom: 5px; }
.guide-grid p { margin-bottom: 0; color: var(--ink-soft); }
.keyboard-note { margin: 18px 0 0; padding: 14px; border-radius: 14px; background: #e8f4df; line-height: 1.5; }
.range-row { display: grid; grid-template-columns: 70px minmax(0,1fr) 48px; align-items: center; gap: 10px; margin: 18px 0; font-weight: 850; }
.range-row input { width: 100%; accent-color: var(--teal); }
.range-row output { text-align: right; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 12px; border-top: 2px solid var(--line); font-weight: 850; }
.toggle-row input { width: 22px; height: 22px; accent-color: var(--teal); }
.end-modal { width: min(560px, 100%); text-align: center; }
.end-emblem { width: 88px; height: 88px; display: grid; place-items: center; margin: 0 auto 16px; border: 4px solid var(--ink); border-radius: 26px; background: var(--yellow); font-size: 3.2rem; transform: rotate(-4deg); }
.end-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.end-stats div { padding: 12px; border: 2px solid var(--line); border-radius: 14px; background: #fff; }
.end-stats span { display: block; color: var(--ink-soft); font-size: .73rem; font-weight: 800; }
.end-stats strong { display: block; margin-top: 3px; font-size: 1.25rem; }
.new-record { padding: 10px; border: 2px solid var(--ink); border-radius: 12px; background: #fff0a9; font-weight: 950; }
.end-modal .button + .button { margin-top: 9px; }

@media (max-width: 1100px) {
  .game-layout { grid-template-columns: 1fr; }
  .side-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .tip-card { display: none; }
}

@media (max-width: 760px) {
  .game-header { flex-wrap: wrap; gap: 6px; padding-top: max(8px, env(safe-area-inset-top)); }
  .game-brand { width: 100%; margin: 0; justify-content: center; }
  .stat { min-width: 0; flex: 1 1 21%; padding: 5px 7px; }
  .stat span { font-size: .59rem; }
  .stat strong { font-size: .88rem; }
  .header-actions { margin-left: auto; }
  .game-layout { padding: 9px; gap: 10px; }
  .message-banner { font-size: .78rem; }
  .canvas-frame { border-width: 3px; border-radius: 16px; }
  .mobile-selection { display: block; }
  .tower-shop { grid-template-columns: 1fr 1fr; gap: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .tower-card { padding: 8px; border-width: 2px; box-shadow: 0 4px 0 var(--ink); }
  .tower-icon { font-size: 1.5rem; }
  .side-panel { display: grid; grid-template-columns: 1fr; }
  .tower-panel { order: -1; }
  .guide-grid { grid-template-columns: 1fr; }
}

@media (max-width: 470px) {
  .menu-screen { padding: 14px; }
  .menu-card { border-radius: 26px; }
  .sun { width: 110px; height: 110px; }
  .menu-bug { display: none; }
  .tower-copy small { display: none; }
  .tower-card { grid-template-columns: auto 1fr auto; }
  .tower-price::before { content: ""; }
  .end-stats { grid-template-columns: 1fr; }
  .range-row { grid-template-columns: 62px 1fr 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* v0.2.0 — Bölüm haritası ve ilerleme */
.record-strip--triple { align-items: stretch; padding: 10px; }
.record-strip--triple > span { flex: 1; display: grid; gap: 3px; padding: 5px 8px; border-right: 2px solid rgba(23,50,74,.13); }
.record-strip--triple > span:last-child { border-right: 0; }
.record-strip--triple small { color: var(--ink-soft); font-size: .66rem; }
.record-strip--triple strong { font-size: 1.05rem; }

.level-screen { flex-direction: column; padding: clamp(18px, 4vw, 42px); background: linear-gradient(145deg, #d9f1df, #fff3c7 48%, #b6dde5); }
.level-screen.screen--active { display: flex; }
.level-header { width: min(1200px, 100%); display: grid; grid-template-columns: 180px minmax(0,1fr) 180px; align-items: center; gap: 20px; margin: 0 auto 22px; }
.level-header h1 { margin-bottom: 6px; font-size: clamp(2rem, 5vw, 4rem); line-height: .95; }
.level-header p { margin-bottom: 0; color: var(--ink-soft); font-weight: 650; }
.level-back { justify-self: start; }
.level-total { justify-self: end; min-width: 150px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px; border: 3px solid var(--ink); border-radius: 18px; background: var(--paper); box-shadow: 0 5px 0 var(--ink); font-size: 1.1rem; }
.level-total span { font-size: 1.45rem; }
.world-tabs { width: min(1200px, 100%); display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 auto 16px; }
.world-tab { min-height: 62px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border: 3px solid var(--ink); border-radius: 18px; background: rgba(255,253,244,.82); box-shadow: 0 5px 0 var(--ink); font-weight: 950; cursor: pointer; }
.world-tab--active { background: var(--yellow); transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.world-tab:disabled { opacity: .48; cursor: not-allowed; }
.world-summary { width: min(1200px, 100%); min-height: 110px; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 18px; margin: 0 auto 16px; padding: 18px 22px; border: 4px solid var(--ink); border-radius: 24px; background: var(--paper); box-shadow: var(--shadow); }
.world-summary__icon { width: 72px; height: 72px; display: grid; place-items: center; border: 3px solid var(--ink); border-radius: 20px; background: var(--yellow); font-size: 2.6rem; }
.world-summary h2 { margin-bottom: 5px; font-size: 1.5rem; }
.world-summary p { margin-bottom: 0; color: var(--ink-soft); }
.world-summary__stars { padding: 10px 14px; border: 2px solid var(--ink); border-radius: 14px; background: #fff4b7; font-weight: 950; white-space: nowrap; }
.level-grid { width: min(1200px, 100%); display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 14px; margin: 0 auto; }
.level-card { position: relative; min-height: 205px; display: flex; flex-direction: column; align-items: stretch; padding: 16px; border: 3px solid var(--ink); border-radius: 22px; background: rgba(255,253,244,.96); box-shadow: 0 6px 0 var(--ink); text-align: left; cursor: pointer; overflow: hidden; }
.level-card:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.02); }
.level-card:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.level-card:disabled { cursor: not-allowed; filter: grayscale(.2); opacity: .65; }
.level-card__number { width: 42px; height: 42px; display: grid; place-items: center; border: 3px solid var(--ink); border-radius: 13px; background: var(--yellow); font-weight: 950; }
.level-card__badge { position: absolute; right: 12px; top: 12px; padding: 5px 8px; border: 2px solid var(--ink); border-radius: 999px; background: #d9f2e2; font-size: .66rem; font-weight: 950; }
.level-card h3 { margin: 15px 0 6px; font-size: 1.05rem; }
.level-card p { flex: 1; margin-bottom: 12px; color: var(--ink-soft); font-size: .8rem; line-height: 1.45; }
.level-card__stars { color: #d19b20; font-size: 1.35rem; letter-spacing: .08em; }
.level-card__lock { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: .78rem; font-weight: 850; }
.level-card--boss { background: linear-gradient(145deg, #fff7dc, #ffd5cb); }
.level-card--boss .level-card__badge { background: #f2a3a0; }

.game-brand { flex-wrap: wrap; }
.game-brand small { width: 100%; padding-left: 40px; margin-top: -5px; color: var(--ink-soft); font-size: .65rem; }
.level-info-card { background: #fff4c3; }
.end-stars { margin: 3px 0 12px; color: #e2a928; font-size: clamp(2.5rem, 8vw, 4.2rem); letter-spacing: .12em; line-height: 1; text-shadow: 0 3px 0 var(--ink); -webkit-text-stroke: 2px var(--ink); }

@media (max-width: 1000px) {
  .level-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .level-header { grid-template-columns: 150px minmax(0,1fr) 150px; }
}

@media (max-width: 720px) {
  .record-strip--triple { display: grid; grid-template-columns: repeat(3,1fr); gap: 0; }
  .record-strip--triple > span { padding: 4px; }
  .record-strip--triple small { font-size: .56rem; }
  .record-strip--triple strong { font-size: .88rem; }
  .level-screen { padding: 12px; }
  .level-header { grid-template-columns: 1fr auto; align-items: start; }
  .level-header > div:nth-child(2) { grid-column: 1 / -1; grid-row: 1; }
  .level-back { grid-column: 1; grid-row: 2; }
  .level-total { grid-column: 2; grid-row: 2; min-width: auto; padding: 10px; }
  .world-tabs { grid-template-columns: 1fr 1fr; }
  .world-tab { min-height: 50px; font-size: .78rem; }
  .world-summary { grid-template-columns: auto 1fr; padding: 14px; }
  .world-summary__stars { grid-column: 1 / -1; text-align: center; }
  .level-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .level-card { min-height: 185px; padding: 13px; }
  .level-info-card { order: -2; }
}

@media (max-width: 420px) {
  .level-grid { grid-template-columns: 1fr; }
  .level-card { min-height: 150px; }
  .world-summary__icon { width: 56px; height: 56px; font-size: 2rem; }
}
