:root{
  --green:#2ecc71;
  --green2:#27ae60;
  --panel: rgba(0,0,0,.55);
  --text: #e9f1ea;
  --muted:#b9c7bd;
  --line: rgba(255,255,255,.12);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
}

/* ===== BACKGROUND BASE (landing) ===== */
.bg{
  background: #0b0f0c url("/static/img/bg4.jpg") center/cover no-repeat fixed;
}

/* ===== TOPBAR (landing) ===== */
.topbar{
  position:fixed;
  top:0; left:0; right:0;
  padding:14px 18px;
  display:flex;
  justify-content:flex-end;
  z-index:10;
}
.topbar-right{display:flex; gap:10px; align-items:center}

/* Contract 022 Пункт 10: Fixed height to match bug-report-btn */
.link-btn{
  color:var(--text);
  text-decoration:none;
  padding:8px 10px;
  border:1px solid var(--line);
  background:rgba(0,0,0,.35);
  border-radius:10px;
  cursor:pointer;
  height: 36px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
}
.link-btn:hover{border-color:rgba(255,255,255,.22)}

/* =========================================================
   LANDING
   ========================================================= */
.center{
  min-height:100%;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding:78px 16px 40px;
}

.hero{
  width:500px;
  height:780px;
  max-width:100%;
  background:  #263d2c;
  border:1px solid rgba(255,255,255,.12);
  border-radius:18px;
  padding:10px 18px 16px;
  backdrop-filter: blur(7px);
  display:flex;
  flex-direction:column;
  gap:10px;
}

.logo{
  display:block;
  max-width:220px;
  width:70%;
  height:auto;
  margin:6px auto 0;
}

.subtitle{
  text-align:center;
  color:var(--muted);
  margin:0 auto 6px;
  line-height:1.25;
  max-width:460px;
  font-size:14px;
}

.play-wrap{display:flex; justify-content:center; margin:6px 0 8px;}
.play-btn{
  display:inline-block;
  width:420px;
  max-width:100%;
  text-align:center;
  padding:14px 18px;
  border-radius:14px;
  background:linear-gradient(180deg, var(--green), var(--green2));
  color:#06210f;
  font-weight:800;
  letter-spacing:.06em;
  text-decoration:none;
  box-shadow: 0 10px 22px rgba(0,0,0,.25);
}
.play-btn:hover{filter:brightness(1.05)}

.auth{
  margin-top:6px;
  border-top:1px solid var(--line);
  padding-top:12px;
}

.auth-title{
  font-weight:700;
  margin-bottom:8px;
  text-align:center;
}

.form{
  display:grid;
  gap:8px;
  width:380px;
  max-width:100%;
  margin:0 auto;
}

.lbl{font-size:13px; color:var(--muted)}

.inp{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.18);
  background:rgba(0,0,0,.35);
  color:var(--text);
  outline:none;
}
.inp:focus{border-color:rgba(46,204,113,.65)}

.row{display:flex; gap:10px; margin-top:6px;}
.btn{
  flex:1;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(46,204,113,.55);
  background:rgba(46,204,113,.22);
  color:var(--text);
  font-weight:700;
  cursor:pointer;
}
.btn:hover{background:rgba(46,204,113,.28)}
.btn-ghost{
  border-color:rgba(255,255,255,.18);
  background:rgba(0,0,0,.25);
}
.btn-ghost:hover{background:rgba(0,0,0,.32)}

.btn-auto{
  border-color:rgba(241,196,15,.55);
  background:rgba(241,196,15,.22);
  color:#f1c40f;
}
.btn-auto:hover{background:rgba(241,196,15,.35)}

.btn-surrender{
  border-color:rgba(231,76,60,.55);
  background:rgba(231,76,60,.22);
  color:#e74c3c;
}
.btn-surrender:hover{background:rgba(231,76,60,.35)}

.btn-danger{
  border-color:rgba(231,76,60,.8);
  background:rgba(231,76,60,.7);
  color:#fff;
}
.btn-danger:hover{background:rgba(231,76,60,.9)}

.modal-buttons{
  display:flex;
  gap:10px;
  margin-top:15px;
  justify-content:center;
}
.modal-buttons .btn{
  flex:1;
  max-width:150px;
}

.msg{
  width:380px;
  max-width:100%;
  margin:0 auto 8px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(0,0,0,.28);
  color:var(--text);
}

/* =========================================================
   GAME
   ========================================================= */
.game-page{
  position:relative;
  min-height:100vh;
  overflow:hidden;
}

.game-bg {
    position: fixed;
    inset: 0;
    background: #0b0f0c url(/static/img/lobby.png) no-repeat;
    background-size: cover;
    background-position: center center;
    z-index: 0;
}

.game-content{
  position:relative;
  z-index:1;
  min-height:100vh;
}

/* ===== GAME TOPBAR (Contract 020 - Fixed header) ===== */
.game-topbar{
  position:fixed;
  top:0;
  left:0;
  right:0;
  z-index:1000;
  height:64px;
  display:grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap:10px;
  align-items:center;
  padding:10px 14px;
  background: #263d2c;
  border-bottom:1px solid var(--line);
  backdrop-filter: blur(3px);
}

/* Body padding for fixed topbar */
.game-page .game-content {
  padding-top: 64px;
}

.game-title{font-weight:800; text-align:center;}
.game-phase{
  text-align:center;
  color: var(--muted);
  font-size:13px;
  margin-top:2px;
}
.game-hint{
  text-align:center;
  font-size:13px;
  margin-top:4px;
  color: #d6ead8;
}
/* Contract 022 Пункт 10: gap=5px, same height buttons */
.game-left{display:flex; align-items:center; gap: 5px;}
.game-right{display:flex; justify-content:flex-end; align-items:center; gap: 5px;}

/* ===== VS BAR ===== */
.vsbar{
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 10px;
  border:1px solid var(--line);
  border-radius:14px;
  background: rgba(0,0,0,.28);
}
.vsbar-race{
  width:28px;
  height:28px;
  object-fit:contain;
}
.vsbar-vs{
  width:22px;
  height:22px;
  object-fit:contain;
  opacity:.95;
}

/* Contract 022: Active turn indicator on vsBar */
.vsbar-race.active-turn {
  box-shadow: 0 0 0 3px #2ecc71, 0 0 12px rgba(46,204,113,.6);
  border-radius: 50%;
  animation: pulse-turn 1.5s ease-in-out infinite;
}
@keyframes pulse-turn {
  0%, 100% { box-shadow: 0 0 0 3px #2ecc71, 0 0 12px rgba(46,204,113,.6); }
  50% { box-shadow: 0 0 0 4px #2ecc71, 0 0 16px rgba(46,204,113,.8); }
}

/* ===== GAME LAYOUT ===== */
.game-wrap{
  width:min(1600px, 100%);
  margin:0 auto;
  padding:16px;
  display:grid;
  gap:36px;
  grid-template-columns: 360px 1fr;
  min-width:0;
}

/* Ensure hidden panels don't affect grid layout */
.game-wrap > [hidden] {
  display: none !important;
}

/* Panels always in first column */
.game-wrap > .panel {
  grid-column: 1;
}

.panel{
  background: #263d2c;
  border:1px solid var(--line);
  border-radius:18px;
  padding:14px;
}
.panel-title {
    font-weight: 800;
    margin-bottom: 10px;
    text-align: center;
}
.muted{color:var(--muted); text-align: center;}
.ready-line{margin:6px 0;}

/* ===== RACE PICK ===== */
.race-row{
  display:flex;
  gap:12px;
  justify-content:space-between;
  flex-wrap:wrap;
}
.race-btn{
  width:68px;
  height:68px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.25);
  cursor:pointer;
  padding:10px;
}
.race-btn:hover{background: rgba(0,0,0,.33)}
.race-btn img{
  width:100%;
  height:100%;
  object-fit:contain;
}

/* ===== CITY TECH ROW ===== */
.tech-row{display:grid; gap:8px;}

.tech-btn{
  width:100%;
  text-align:left;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.25);
  color: var(--text);
  cursor:pointer;
}
.tech-btn:hover{background: rgba(0,0,0,.33)}
.tech-btn.selected{
  border-color: rgba(46,204,113,.6);
  background: rgba(46,204,113,.18);
}
.tech-btn.placed{
  opacity:.55;
  cursor:not-allowed;
}

/* ===== RIGHT AREA: BOARD + LOG (Contract 021: log right of board) ===== */
/* gap: 36px - same as .game-wrap gap between gamePanel and board-area */
.board-area{
  display:grid;
  grid-template-columns: auto 360px; /* Match .game-log width (Contract 022 Пункт 11) */
  grid-template-rows: 1fr;
  gap:36px;
  min-width:0;
  align-items: stretch;
  justify-content: space-evenly;
}

/* Desktop: Log panel right of board, same height as board-wrap */
.board-area > .game-log{
  height: auto;
  min-height: 600px;
  max-height: 867px; /* Match board height: 847px + padding */
  align-self: stretch;
}

.board-wrap{
  position: relative;
  display: inline-block; /* не растягивается шире контента */

  /* Ширина = board (720px) + padding (10×2) = 740px */
  width: 740px;
  box-sizing: border-box; /* padding включён в width */
  padding: 10px; /* 10px отступ вокруг board */

  background: linear-gradient(145deg, #2a4530, #1e3324);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 18px;
  overflow: visible;
  /* Enhanced depth with multiple shadows */
  box-shadow:
    0 8px 20px rgba(0,0,0,0.4),
    0 2px 6px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.1);
}

/* ===== HEXAGONAL BOARD (9x9 flat-top hex grid) ===== */
/* Contract 022 Пункт 12: Эталонные стили .board */
.board{
  --hex-w: 100px;
  --hex-h: 87px;
  position: relative;
  width: 720px;
  height: 847px;
  background-color: #0b0f0c;
  /* background-image: url(/static/img/landscape/board_bg_4.jpg); */
  background-repeat: repeat;
  background-size: 200px 200px;
  background-color: #5c755d;
  /* border: 2px solid rgba(255, 255, 255, .25); */
  border-radius: 12px;
  overflow: visible;
}

/* Visual flip for Player 2 in online mode */
.board.flipped {
  transform: scaleY(-1);
}
.board.flipped .cell {
  transform: scaleY(-1);
}

/* Flat-top hexagonal cell */
.cell{
  position: absolute;
  width: var(--hex-w);
  height: var(--hex-h);
  cursor: pointer;
  overflow: visible !important;
}

/* Flat-top hex shape using clip-path */
.cell::before {
  content: '';
  position: absolute;
  inset: 0;
  /* Flat-top hexagon: 25%/75% at top/bottom, pointy sides */
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  background: rgba(30,50,35,.85);
  border: none;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.15);
  pointer-events: none;
  z-index: 0;
}

.cell:hover::before {
  background: rgba(50,90,60,.95);
}

/* Coordinate label - top-left in hex */
.coord{
  position: absolute;
  top: 8px;
  left: 28px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,.6);
  user-select: none;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
  z-index: 10;
  pointer-events: none;
}

/* Contract 022 Пункт 12: Эталонные стили .content */
.content{
  position: absolute;
  inset: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  z-index: 1;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 -1px 3px rgba(255, 255, 255, 0.1);
}

/* магма (пустая клетка) */
.content.magma{
  /* background-image: url("/static/img/landscape/water-6.png"); */
  /* background-size: cover; */
  background-position: center;
  border-radius: 13px;
  /* background-repeat: no-repeat; */
  background: rgba(0, 0, 0, .28);
}

/* Стопка: гексагональная форма (Contract 021) */
/* Основные стили .stack-tile определены ниже в секции "STACK TILE (HEXAGONAL)" */

.panel game-log {
  height: 780px;
}

/* ===== GAME LOG ===== */
/* Contract 022 Пункт 11: Desktop width 360px */
.game-log{
  width: 360px;
}
.game-log-body{
  height: 780px;
  overflow:auto;
  padding:8px 10px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.20);
}
.game-log-line{
  font-size:13px;
  line-height:1.35;
  padding:6px 4px;
  border-bottom:1px dashed rgba(255,255,255,.10);
}
.game-log-line:last-child{border-bottom:none;}

/* ===== STACK UI ===== */
.stack-row {
    display: grid;
    grid-template-columns: 330px;
    gap: 9px;
    align-items: center;
    margin-top: 10px;
    justify-content: center;
}

.stack-box {
    display: grid;
    border: 1px solid rgba(255, 255, 255, .16);
    background: rgba(0, 0, 0, .25);
    border-radius: 16px;
    padding: 10px;
    cursor: pointer;
    user-select: none;
    align-items: center;
    justify-content: center;
    justify-items: center;
}
  
.stack-box:hover{background: rgba(0,0,0,.33)}
.stack-box.disabled{
  opacity:.5;
  cursor:not-allowed;
}

.stack-title{
  font-weight:900;
  letter-spacing:.08em;
  text-align: center;
  font-size:12px;
  color: rgba(255,255,255,.75);
}

/* СТОПКА: Гексагональная форма - см. секцию "STACK TILE (HEXAGONAL)" */

.stack-sub{
  margin-top:8px;
  font-size:12px;
  color: var(--muted);
}

/* ===== MODAL ===== */
.modal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.55);
  z-index:50;
}
.modal-card{
  width:min(520px, calc(100% - 24px));
  background: rgba(0,0,0,.70);
  border:1px solid rgba(255,255,255,.16);
  border-radius:18px;
  padding:16px 16px 14px;
  backdrop-filter: blur(6px);
}
.modal-title{
  font-weight:900;
  margin-bottom:8px;
}
.modal-text{
  white-space:pre-line;
  color: var(--text);
  line-height:1.35;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1400px){
  .board-area{grid-template-columns: 1fr;}
  .game-log{min-height: 300px;}
  .game-log-body{min-height: 250px; max-height: 300px;}
}
@media (max-width: 1100px){
  .game-wrap{grid-template-columns: 1fr;}
  .board{
    --hex-w: 70px;
    --hex-h: 61px;
    width: 510px;
    height: 600px;
  }
  .board-wrap{width: 530px;} /* board 510 + padding 20 */
  .unit-badge{width: clamp(36px, 4.5vw, 48px); height: clamp(36px, 4.5vw, 48px);}
  .building-img{width:45px; height:45px;}
  .coord{font-size:9px; left:20px; top:6px;}
}
@media (max-width: 800px){
  .board{
    --hex-w: 55px;
    --hex-h: 48px;
    width: 400px;
    height: 480px;
  }
  .board-wrap{width: 420px;} /* board 400 + padding 20 */
  .unit-badge{width: clamp(28px, 4vw, 38px); height: clamp(28px, 4vw, 38px);}
  .building-img{width:36px; height:36px;}
  .coord{font-size:8px; left:15px; top:5px;}
  .hero{height:auto;}
}
/* Contract 020: Additional badge responsiveness */
@media (max-width: 768px){
  .unit-badge{width: 28px; height: 28px;}
}

.modal[hidden]{
  display:none !important;
}


/* ===== VS BAR ===== */
.vsbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.vsbar-race{
  width:34px;
  height:34px;
  object-fit:contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.35));
}
.vsbar-vs{
  width:26px;
  height:26px;
  object-fit:contain;
  opacity:.9;
}

/* ===== RACE PICK BUTTONS ===== */
.race-row{
  display:flex;
  gap:12px;
  justify-content:center;
  flex-wrap:wrap;
}
.race-btn{
  width:72px;
  height:72px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.25);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
}
.race-btn:hover{ background: rgba(0,0,0,.33); border-color: rgba(46,204,113,.35); }
.race-btn img{
  width:56px;
  height:56px;
  object-fit:contain;
}


/* ===== STACK TILE (HEXAGONAL - Contract 021) ===== */
.stack-tile{
  width:100px;
  height:87px;              /* hex aspect ratio = sqrt(3)/2 ≈ 0.866 */
  margin-top:8px;
  border:none;
  /* Flat-top hexagon clip-path */
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  background-size: cover;
  background-position: center;
  background-repeat:no-repeat;
  background-color: rgba(30,50,35,.85);
}
.stack-tile.empty{
  background-color: rgba(255,255,255,.08);
  background-image: none;
}

/* ===== UNIT PANEL ===== */
.unit-panel{
  margin-top:10px;
  border-top:1px solid rgba(255,255,255,.10);
  padding-top:10px;
}
.unit-panel-title{
  font-weight:800;
  margin-bottom:6px;
  text-align: center;
}

/* ===== Contract 020 - Vertical action buttons ===== */
.action-buttons{
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.action-buttons .btn{
  width: 100%;
  padding: 14px 20px;
  font-weight: 700;
}

/* Contract 022 Пункт 13: btn-produce зелёный #3e6940 */
.action-buttons .btn-produce{
  background: #3e6940;
  border-color: rgb(118, 119, 117);
  color: #fff;
}
.action-buttons .btn-produce:hover{
  background: #4a7d4c;
}

.action-buttons .btn-surrender{
  background: rgba(244, 67, 54, 0.2);
  border: 1px solid #f44336;
  color: #f44336;
}
.action-buttons .btn-surrender:hover{
  background: rgba(244, 67, 54, 0.35);
}

/* End turn button states */
.btn-end-turn{
  border-color:rgba(255,255,255,.18);
  background:rgba(0,0,0,.25);
  transition: all 0.3s ease;
}
.btn-end-turn:hover{
  background:rgba(0,0,0,.32);
}
.btn-end-turn.urgent{
  background: rgba(200,40,40,.85) !important;
  border-color: rgba(255,60,60,.9) !important;
  color: #fff !important;
  font-weight: 800;
  animation: pulse-urgent 1s infinite;
  box-shadow: 0 0 15px rgba(255,60,60,.5);
}
.btn-end-turn.urgent:hover{
  background: rgba(220,50,50,.95) !important;
}
@keyframes pulse-urgent{
  0%, 100% { box-shadow: 0 0 10px 2px rgba(255,60,60,.4); }
  50% { box-shadow: 0 0 20px 6px rgba(255,60,60,.6); }
}

/* Disabled buttons */
.btn.disabled, .btn:disabled{
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Production panel - Contract 021: inline panel hidden, use modal only */
/* Legacy .produce-panel styles kept for backward compatibility but panel is hidden via HTML hidden attribute */
.produce-title{
  font-weight:700;
  font-size:13px;
  margin-bottom:10px;
  color: var(--muted);
}
.produce-units{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-bottom:10px;
}
.produce-unit-btn{
  display:flex;
  flex-direction:column;
  align-items:center;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.25);
  cursor:pointer;
  transition: all 0.2s;
  min-width:70px;
}
.produce-unit-btn:hover{
  background: rgba(46,204,113,.15);
  border-color: rgba(46,204,113,.4);
}
.produce-unit-btn.disabled{
  opacity:0.35;
  cursor:not-allowed;
}
.produce-unit-btn.disabled:hover{
  background: rgba(0,0,0,.25);
  border-color: rgba(255,255,255,.16);
}
.produce-unit-btn img{
  width:48px;
  height:48px;
  object-fit:contain;
  margin-bottom:6px;
}
.produce-unit-btn .unit-name{
  font-size:11px;
  color: var(--text);
  font-weight:600;
}
.produce-unit-btn .unit-limit{
  font-size:10px;
  color: var(--muted);
  margin-top:2px;
}
.btn-sm{
  padding:6px 12px;
  font-size:12px;
}

/* ===== UNITS OVERLAY (v2.0 with images, hex-adapted) ===== */
/* Contract 020 - Adaptive unit badges using clamp() */
.unit-badge{
  position:absolute;
  left:50%;
  top:50%;
  transform: translate(-50%, -50%);
  width: clamp(40px, 5vw, 65px);
  height: clamp(40px, 5vw, 65px);
  max-width: 100%;
  max-height: 100%;
  border-radius:10px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:18px;
  user-select:none;
  z-index:10;
}
.unit-badge.player{
  filter: drop-shadow(0 2px 4px rgba(46,204,113,.6));
}
.unit-badge.ai{
  filter: drop-shadow(0 2px 4px rgba(231,76,60,.5));
}
.unit-badge.activated{
  opacity: 0.5;
}
.unit-badge.blocking{
  outline: 2px dashed rgba(255,215,0,.7);
  outline-offset: 2px;
}

.unit-img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
}

/* HP Badge for units (right side, red) */
.hp-badge{
  position:absolute;
  top:-6px;
  right:-6px;
  min-width:22px;
  height:22px;
  border-radius:11px;
  background: rgba(231,76,60,1);
  color: #fff;
  font-size:13px;
  font-weight:900;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0 5px;
  border: 2px solid rgba(0,0,0,.5);
  z-index: 100 !important;
  box-shadow: 0 2px 4px rgba(0,0,0,.3);
}

/* ATK Badge for units (left side, blue) */
.atk-badge{
  position:absolute;
  top:-6px;
  left:-6px;
  min-width:22px;
  height:22px;
  border-radius:11px;
  background: rgba(52,152,219,1);
  color: #fff;
  font-size:13px;
  font-weight:900;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0 5px;
  border: 2px solid rgba(0,0,0,.5);
  z-index: 100 !important;
  box-shadow: 0 2px 4px rgba(0,0,0,.3);
}

/* HP Badge for buildings (top right, same as units) */
.hp-badge.building-hp{
  top: 5px;
  right: 15px;
  bottom:auto;
  min-width:26px;
  height:26px;
  border-radius:13px;
  font-size:15px;
  font-weight:900;
  background: rgba(231,76,60,1);
  z-index: 100 !important;
}

/* ===== BUILDING IMAGES (hex-adapted) ===== */
.building-img{
  position:absolute;
  left:50%;
  top:50%;
  transform: translate(-50%, -50%);
  width: 70px;
  height: 70px;
  object-fit:contain;
  object-position: center;
  z-index:3;
}

.content.building{
  font-size:36px; /* fallback emoji size */
}

/* Hex cell selection states */
.cell.selected::before {
  background: rgba(46,204,113,.5) !important;
  box-shadow: inset 0 0 0 3px rgba(46,204,113,.8);
}

.cell.attackable {
  animation: hex-glow-attack 1s infinite;
}
.cell.attackable::before {
  background: rgba(231,76,60,.5) !important;
  box-shadow: inset 0 0 0 3px rgba(231,76,60,.9);
}

@keyframes hex-glow-attack {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Old hex-pulse-attack replaced by hex-glow-attack above */

/* ===== Attack Visualization ===== */
.attack-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* Hit effect on target cell */
.cell.hit-effect {
  animation: hit-shake 150ms ease-out;
}
.cell.hit-effect .unit-badge {
  box-shadow: 0 0 15px 5px rgba(255,100,100,0.8);
}

@keyframes hit-shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 0); }
  50% { transform: translate(3px, 0); }
  75% { transform: translate(-2px, 0); }
}

/* Death fade-out effect */
.cell.death-fade .unit-badge {
  animation: death-fadeout 250ms ease-out forwards;
}

@keyframes death-fadeout {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.5); }
}

/* Melee attacker during dash */
.cell.melee-dash .unit-badge {
  transition: transform 150ms ease-out;
  z-index: 200;
}

/* Input lock overlay */
.input-locked {
  pointer-events: none !important;
}

/* Movable cells - show dot indicator like chess */
.cell.movable::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  background: radial-gradient(circle, #39FF14, #2ecc71);
  border-radius: 50%;
  z-index: 5;
  box-shadow: 0 0 12px #39FF14, 0 0 20px rgba(57,255,20,.6), inset 0 -2px 4px rgba(0,0,0,0.3);
}

.cell.movable::before {
  background: rgba(57,255,20,.15) !important;
  box-shadow: inset 0 0 0 2px rgba(57,255,20,.4);
}


.produce-panel {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  background: rgba(0,0,0,.18);
}

.produce-title {
  font-weight: 800;
  font-size: 13px;
  color: rgba(255,255,255,.85);
  margin-bottom: 8px;
}

.produce-units {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.produce-unit {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(46,204,113,.35);
  background: rgba(46,204,113,.10);
  cursor: pointer;
  user-select: none;
}

.produce-unit:hover {
  background: rgba(46,204,113,.16);
}

.produce-unit img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.produce-unit .name {
  font-size: 12px;
  font-weight: 800;
}

.produce-unit .meta {
  font-size: 11px;
  color: rgba(255,255,255,.65);
}

/* ===== Ensure badges are not clipped by board/cells ===== */
.board-wrap,
.board,
.cell {
  overflow: visible !important;
}

/* Unit container should be above grid */
.cell .unit,
.cell .unit-sprite,
.cell .unit-img,
.unit {
  position: relative;
  z-index: 50;
}

/* Badges top-most */
.hp-badge,
.atk-badge {
  z-index: 9999 !important;
  pointer-events: none;
}


.btn.disabled,
.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}


/* ===== Victory overlay ===== */
.victory-overlay[hidden] { display: none; }
.victory-overlay{
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.72);
}

.victory-card{
  width: min(520px, 92vw);
  background: rgba(20,20,20,.96);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 18px;
  padding: 18px 18px 16px;
  text-align: center;
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
}

.victory-title{
  font-size: 34px;
  font-weight: 900;
  margin-bottom: 10px;
  color: #2ecc71;
}

.victory-title.defeat{
  color: #e74c3c;
}

.victory-emblem{
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin: 6px auto 10px;
  display: block;
}

.victory-name{
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 14px;
  color: rgba(255,255,255,.92);
}

/* ==========================================================================
   MOBILE ADAPTATION (Contract 006)
   Target: smartphones 360×640+, tablets 768×1024+
   ========================================================================== */

/* ===== Touch-friendly: minimum 44×44px tap targets ===== */
@media (pointer: coarse) {
  .btn,
  .link-btn,
  .race-btn,
  .tech-btn,
  .produce-unit-btn,
  .stack-box {
    min-height: 44px;
    min-width: 44px;
  }

  /* Remove hover effects on touch devices - use :active instead */
  .btn:hover,
  .link-btn:hover,
  .race-btn:hover,
  .tech-btn:hover,
  .stack-box:hover,
  .cell:hover,
  .produce-unit-btn:hover {
    /* Reset hover to normal state */
  }

  .btn:active,
  .link-btn:active {
    background: rgba(46,204,113,.35);
  }

  .race-btn:active {
    background: rgba(0,0,0,.4);
    border-color: rgba(46,204,113,.5);
  }

  .tech-btn:active {
    background: rgba(0,0,0,.4);
  }

  .cell:active {
    opacity: 0.85;
  }
}

/* ===== Log Toggle Button (Contract 021: REMOVED - log always visible) ===== */
.log-toggle-btn {
  display: none !important; /* Contract 021: полностью скрыта */
}

/* ===== Contract 021: Draggable Log Panel REMOVED ===== */
/* Log is now always visible in board-area */

/* ===== TABLET PORTRAIT (768px and below) ===== */
@media (max-width: 768px) {
  /* Game layout: single column */
  .game-wrap {
    grid-template-columns: 1fr;
    padding: 10px;
    gap: 12px;
  }

  .board-area {
    grid-template-columns: 1fr;
    grid-column: 1;
    grid-row: auto;
  }

  /* Board sizing for tablets */
  .board {
    grid-template-columns: repeat(var(--cols), 70px);
    grid-auto-rows: 70px;
  }

  .board-wrap {
    width: auto; /* на мобильных — авто под контент */
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Unit and building scaling */
  .unit-badge {
    width: 55px;
    height: 55px;
  }

  .building-img {
    width: 60px;
    height: 60px;
  }

  /* Contract 021: Game log under board-wrap on mobile (not fixed) */
  .game-log {
    position: static;
    width: 100%;
    min-height: 200px;
    max-height: 300px;
    border-radius: 18px;
    z-index: auto;
    box-shadow: none;
  }

  .game-log-body {
    min-height: 150px;
    max-height: 240px;
  }

  /* Contract 021: log-toggle-btn hidden on all devices */
  .log-toggle-btn {
    display: none !important;
  }

  /* Topbar adjustments */
  .game-topbar {
    grid-template-columns: auto 1fr auto;
    padding: 8px 10px;
    gap: 8px;
  }

  .game-title {
    font-size: 14px;
  }

  .game-phase,
  .game-hint {
    font-size: 11px;
  }

  .link-btn {
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Panel adjustments */
  .panel {
    padding: 12px;
  }

  .panel-title {
    font-size: 15px;
  }

  /* Race buttons larger for touch */
  .race-btn {
    width: 72px;
    height: 72px;
  }

  /* Stack control */
  .stack-row {
    grid-template-columns: 1fr;
  }

  .stack-box {
    padding: 12px;
  }

  /* Contract 021: Hex stack tile responsive */
  .stack-tile {
    width: 80px;
    height: 70px; /* hex ratio */
  }

  /* Hero (landing page) */
  .hero {
    width: 100%;
    max-width: 100%;
    height: auto;
    padding: 16px;
  }

  .center {
    padding: 60px 12px 20px;
  }

  /* VS bar */
  .vsbar {
    padding: 8px 12px;
  }

  .vsbar-race {
    width: 30px;
    height: 30px;
  }
}

/* ===== SMARTPHONE (480px and below) ===== */
@media (max-width: 480px) {
  /* Board: fit screen width with smaller hex cells */
  .board {
    --hex-w: 45px;
    --hex-h: 39px;
    width: 320px;
    height: 400px;
  }

  .board-wrap {
    width: auto; /* на телефонах — авто под контент */
    padding: 10px;
    border-radius: 12px;
    overflow-x: hidden; /* No horizontal scroll on small phones */
  }

  /* Prevent horizontal overflow */
  .game-content {
    overflow-x: hidden;
  }

  .game-wrap {
    padding: 8px;
    gap: 10px;
  }

  /* Unit badges smaller */
  .unit-badge {
    width: calc((100vw - 44px) / 8 - 12px);
    height: calc((100vw - 44px) / 8 - 12px);
    min-width: 32px;
    min-height: 32px;
  }

  .building-img {
    width: calc((100vw - 44px) / 8 - 8px);
    height: calc((100vw - 44px) / 8 - 8px);
    min-width: 35px;
    min-height: 35px;
  }

  /* HP/ATK badges smaller */
  .hp-badge,
  .atk-badge {
    min-width: 16px;
    height: 16px;
    font-size: 10px;
    padding: 0 3px;
  }

  .hp-badge.building-hp {
    min-width: 18px;
    height: 18px;
    font-size: 11px;
  }

  /* Coordinate labels smaller */
  .coord {
    font-size: 8px;
    top: 2px;
    left: 3px;
  }

  /* Topbar compact */
  .game-topbar {
    padding: 6px 8px;
    gap: 6px;
  }

  .game-title {
    font-size: 12px;
  }

  .game-mid {
    text-align: center;
  }

  .game-phase,
  .game-hint {
    font-size: 10px;
    margin-top: 2px;
  }

  .link-btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  /* Race buttons */
  .race-row {
    gap: 8px;
    justify-content: center;
  }

  .race-btn {
    width: 64px;
    height: 64px;
    padding: 8px;
  }

  .race-btn img {
    width: 44px;
    height: 44px;
  }

  /* Tech buttons full width */
  .tech-btn {
    padding: 12px;
    font-size: 13px;
  }

  /* Action buttons */
  .btn {
    padding: 12px 14px;
    font-size: 14px;
  }

  .row {
    flex-direction: column;
    gap: 8px;
  }

  .row .btn {
    width: 100%;
  }

  /* Stack - Contract 021: Hex proportions */
  .stack-tile {
    width: 70px;
    height: 61px; /* hex ratio */
  }

  .stack-title {
    font-size: 11px;
  }

  .stack-sub {
    font-size: 11px;
  }

  /* Production panel */
  .produce-units {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .produce-unit {
    padding: 10px 8px;
    flex-direction: column;
    text-align: center;
  }

  .produce-unit img {
    width: 32px;
    height: 32px;
  }

  /* Info texts */
  .muted,
  .subtitle {
    font-size: 12px;
  }

  .stack-info .muted {
    font-size: 11px;
  }

  /* Modals */
  .modal-card {
    width: calc(100% - 20px);
    padding: 14px;
  }

  .modal-title {
    font-size: 16px;
  }

  .modal-text {
    font-size: 13px;
  }

  /* Victory overlay */
  .victory-card {
    width: calc(100% - 20px);
    padding: 16px;
  }

  .victory-title {
    font-size: 26px;
  }

  .victory-emblem {
    width: 90px;
    height: 90px;
  }

  .victory-name {
    font-size: 15px;
  }

  /* Game log on phone */
  .game-log {
    max-height: 50vh;
  }

  .game-log-body {
    max-height: calc(50vh - 50px);
    padding: 6px 8px;
  }

  .game-log-line {
    font-size: 12px;
    padding: 5px 6px;
  }

  /* Log toggle button position */
  .log-toggle-btn {
    bottom: 12px;
    right: 12px;
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
}

/* ===== VERY SMALL PHONES (360px and below) ===== */
@media (max-width: 360px) {
  .board {
    --hex-w: 38px;
    --hex-h: 33px;
    width: 280px;
    height: 340px;
  }

  .unit-badge {
    width: 26px;
    height: 26px;
  }

  .building-img {
    width: 28px;
    height: 28px;
  }

  .hp-badge,
  .atk-badge {
    min-width: 14px;
    height: 14px;
    font-size: 9px;
    top: -2px;
  }

  .atk-badge {
    left: -2px;
  }

  .hp-badge {
    right: -2px;
  }

  .coord {
    font-size: 7px;
  }

  .game-title {
    font-size: 11px;
  }

  .race-btn {
    width: 56px;
    height: 56px;
  }

  /* Contract 021: Hex proportions */
  .stack-tile {
    width: 60px;
    height: 52px; /* hex ratio */
  }
}

/* ===== LANDSCAPE ORIENTATION ON MOBILE ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .game-topbar {
    padding: 4px 10px;
  }

  .game-title {
    font-size: 12px;
  }

  .game-phase,
  .game-hint {
    display: none;
  }

  .game-wrap {
    padding: 6px;
  }

  .panel {
    padding: 8px;
  }

  .game-log {
    max-height: 60vh;
  }

  /* Allow horizontal layout in landscape */
  .game-wrap {
    grid-template-columns: minmax(200px, 300px) 1fr;
  }

  .board-area {
    grid-template-columns: 1fr;
  }
}

/* ===== PREVENT ZOOM ON INPUT FOCUS (iOS) ===== */
@media (max-width: 768px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ===== SAFE AREA INSETS (iPhone X+) ===== */
@supports (padding: env(safe-area-inset-bottom)) {
  .game-log {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  .log-toggle-btn {
    bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .game-topbar {
    padding-top: calc(10px + env(safe-area-inset-top));
  }
}

/* ===== LANDING PAGE MOBILE ===== */
@media (max-width: 480px) {
  .topbar {
    padding: 10px 12px;
  }

  .topbar-right {
    gap: 6px;
  }

  .link-btn {
    padding: 10px 12px;
    font-size: 13px;
  }

  .center {
    padding: 56px 10px 20px;
  }

  .hero {
    padding: 14px;
    border-radius: 14px;
  }

  .logo {
    max-width: 180px;
  }

  .subtitle {
    font-size: 13px;
  }

  .auth-title {
    font-size: 15px;
  }

  .form {
    gap: 6px;
  }

  .lbl {
    font-size: 12px;
  }

  .inp {
    padding: 12px 14px;
    font-size: 16px; /* Prevents zoom on iOS */
    border-radius: 10px;
  }

  .btn {
    padding: 14px 16px;
    font-size: 15px;
    min-height: 48px;
  }

  .row {
    gap: 8px;
    margin-top: 10px;
  }

  .msg {
    font-size: 13px;
    padding: 10px;
  }

  .play-btn {
    padding: 16px 20px;
    font-size: 16px;
    border-radius: 12px;
  }
}

@media (max-width: 360px) {
  .center {
    padding: 50px 8px 16px;
  }

  .hero {
    padding: 12px;
  }

  .logo {
    max-width: 160px;
  }

  .subtitle {
    font-size: 12px;
  }

  .btn {
    padding: 12px 14px;
    font-size: 14px;
  }

  .inp {
    padding: 10px 12px;
  }
}

/* ===== Rating Toast (Contract 013) ===== */
.rating-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(20,20,20,0.95);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 14px;
  padding: 16px 20px;
  z-index: 9999;
  animation: ratingSlideIn 0.3s ease-out;
}

.rating-toast.fade-out {
  animation: ratingSlideOut 0.3s ease-out forwards;
}

@keyframes ratingSlideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes ratingSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* ===== Bug Report Modal (Contract 014) ===== */
/* Contract 022 Пункт 10: Fixed height to match link-btn */
.bug-report-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.4);
  border-radius: 10px;
  color: #e9f1ea;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  height: 36px;
  box-sizing: border-box;
}

.bug-report-btn:hover {
  background: rgba(231, 76, 60, 0.25);
  border-color: rgba(231, 76, 60, 0.6);
}

.bug-report-btn-icon {
  font-size: 14px;
}

/* Bug Report Modal Overlay */
.bug-report-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.bug-report-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* Bug Report Modal Card */
.bug-report-modal {
  background: linear-gradient(135deg, #1a2e1f 0%, #0f1a12 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  padding: 28px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.25s ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.bug-report-overlay.visible .bug-report-modal {
  transform: scale(1) translateY(0);
}

.bug-report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.bug-report-title {
  font-size: 20px;
  font-weight: 800;
  color: #e9f1ea;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.bug-report-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #b9c7bd;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bug-report-close:hover {
  background: rgba(231, 76, 60, 0.3);
  color: #fff;
}

.bug-report-form,
.bug-report-modal form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bug-report-modal form .bug-report-input,
.bug-report-modal form .bug-report-textarea,
.bug-report-modal form .bug-report-file-label {
  width: 100%;
  box-sizing: border-box;
}

.bug-report-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bug-report-label {
  font-size: 13px;
  font-weight: 600;
  color: #b9c7bd;
}

.bug-report-label .required {
  color: #e74c3c;
}

.bug-report-input,
.bug-report-textarea {
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #e9f1ea;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.bug-report-input:focus,
.bug-report-textarea:focus {
  outline: none;
  border-color: rgba(46, 204, 113, 0.5);
}

.bug-report-textarea {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
}

.bug-report-file-wrapper {
  position: relative;
}

.bug-report-file-input {
  display: none;
}

.bug-report-file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  color: #b9c7bd;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bug-report-file-label:hover {
  border-color: rgba(46, 204, 113, 0.4);
  background: rgba(46, 204, 113, 0.05);
}

.bug-report-file-label.has-file {
  border-color: rgba(46, 204, 113, 0.5);
  background: rgba(46, 204, 113, 0.1);
  color: #2ecc71;
}

.bug-report-file-preview {
  margin-top: 10px;
  max-width: 100%;
  max-height: 150px;
  border-radius: 8px;
  object-fit: contain;
}

.bug-report-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.bug-report-submit {
  flex: 1;
  padding: 14px 20px;
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bug-report-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
}

.bug-report-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.bug-report-cancel {
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #b9c7bd;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bug-report-cancel:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #e9f1ea;
}

.bug-report-error {
  padding: 10px 14px;
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.3);
  border-radius: 8px;
  color: #e74c3c;
  font-size: 13px;
}

.bug-report-success {
  padding: 10px 14px;
  background: rgba(46, 204, 113, 0.15);
  border: 1px solid rgba(46, 204, 113, 0.3);
  border-radius: 8px;
  color: #2ecc71;
  font-size: 13px;
}

/* ===== Cell Hint Panel (Contract 015) ===== */
.cell-hint-panel {
  margin-top: 12px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  animation: hintFadeIn 0.2s ease;
}

.cell-hint-panel[hidden] {
  display: none;
}

@keyframes hintFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cell-hint-content {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.cell-hint-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cell-hint-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px;
}

.cell-hint-title {
  font-size: 15px;
  font-weight: 700;
  color: #2ecc71;
}

.cell-hint-subtitle {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}

.cell-hint-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 12px;
  margin-bottom: 10px;
}

.cell-hint-stat {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.cell-hint-stat-label {
  color: rgba(255, 255, 255, 0.7);
}

.cell-hint-stat-value {
  font-weight: 700;
  color: #e9f1ea;
}

.cell-hint-stat-value.hp-full {
  color: #2ecc71;
}

.cell-hint-stat-value.hp-damaged {
  color: #f1c40f;
}

.cell-hint-stat-value.hp-critical {
  color: #e74c3c;
}

.cell-hint-section {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.cell-hint-section-title {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.cell-hint-bonus {
  font-size: 12px;
  padding: 4px 0;
  color: rgba(255, 255, 255, 0.85);
}

.cell-hint-bonus.positive {
  color: #2ecc71;
}

.cell-hint-bonus.negative {
  color: #e74c3c;
}

.cell-hint-bonus.neutral {
  color: #f1c40f;
}

/* Tile hint specific */
.cell-hint-tile-effects {
  margin-top: 8px;
}

.cell-hint-effect {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 0;
}

.cell-hint-effect-icon {
  font-size: 14px;
}

/* ===== Contract 020: Produce Unit Modal ===== */
.produce-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.produce-modal-card {
  background: linear-gradient(135deg, #1a2e1f 0%, #0f1a12 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  padding: 24px;
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95);
  animation: modalSlideIn 0.2s ease forwards;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

@keyframes modalSlideIn {
  from { transform: scale(0.95) translateY(10px); }
  to { transform: scale(1) translateY(0); }
}

.produce-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.produce-modal-title {
  font-size: 20px;
  font-weight: 800;
  color: #2ecc71;
}

.produce-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #b9c7bd;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.produce-modal-close:hover {
  background: rgba(231, 76, 60, 0.3);
  color: #fff;
}

.produce-modal-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.produce-modal-units {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.produce-modal-unit {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.produce-modal-unit:hover:not(.disabled) {
  background: rgba(46, 204, 113, 0.15);
  border-color: rgba(46, 204, 113, 0.4);
  transform: translateY(-2px);
}

.produce-modal-unit.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.produce-unit-sprite {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.produce-unit-sprite img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.produce-unit-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.produce-unit-name {
  font-size: 15px;
  font-weight: 700;
  color: #e9f1ea;
}

.produce-unit-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
}

.produce-unit-stats .stat {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
}

.produce-unit-stats .stat.hp {
  color: #e74c3c;
}

.produce-unit-stats .stat.atk {
  color: #3498db;
}

.produce-unit-stats .stat.range {
  color: #f1c40f;
}

.produce-unit-stats .stat.move {
  color: #9b59b6;
}

.produce-unit-limit {
  font-size: 11px;
  color: var(--muted);
  margin-top: auto;
}

.produce-unit-limit.at-limit {
  color: #e74c3c;
}

.produce-modal-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

.produce-modal-actions {
  display: flex;
  justify-content: flex-end;
}

/* Mobile adjustments for produce modal */
@media (max-width: 480px) {
  .produce-modal-units {
    grid-template-columns: 1fr;
  }

  .produce-modal-card {
    padding: 16px;
    max-height: 90vh;
  }

  .produce-unit-sprite {
    width: 50px;
    height: 50px;
  }

  .produce-unit-name {
    font-size: 14px;
  }

  .produce-unit-stats {
    font-size: 11px;
  }
}

/* ============================================
   CONTRACT 029: PASSWORD RECOVERY
   ============================================ */

/* Auth footer - forgot password link */
.auth-footer {
  margin-top: 16px;
  text-align: center;
}

.forgot-password-link {
  color: var(--accent, #4caf50);
  font-size: 14px;
  text-decoration: none;
  transition: color 0.2s;
}

.forgot-password-link:hover {
  color: #45a049;
  text-decoration: underline;
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.modal-overlay[hidden] {
  display: none;
}

/* Forgot password modal */
.forgot-password-modal,
.recovery-success-modal {
  background: var(--panel, #1e1e1e);
  border: 2px solid var(--line, #333);
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.forgot-password-modal .modal-header,
.recovery-success-modal .modal-header {
  padding: 20px;
  border-bottom: 2px solid var(--line, #333);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.forgot-password-modal .modal-header h2,
.recovery-success-modal .modal-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--text, #fff);
}

.modal-close {
  background: none;
  border: none;
  font-size: 32px;
  color: var(--muted, #999);
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text, #fff);
}

.forgot-password-modal .modal-body,
.recovery-success-modal .modal-body {
  padding: 24px;
}

.modal-description {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted, #999);
  margin-bottom: 20px;
}

/* Form elements */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text, #fff);
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--line, #333);
  border-radius: 8px;
  color: var(--text, #fff);
  font-size: 15px;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent, #4caf50);
}

.form-control::placeholder {
  color: var(--muted, #666);
}

.input-hint {
  font-size: 12px;
  color: var(--muted, #666);
  margin-top: 6px;
}

/* Alert */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.alert-info {
  background: rgba(33, 150, 243, 0.1);
  border: 1px solid rgba(33, 150, 243, 0.3);
  color: #64b5f6;
}

.alert strong {
  font-weight: 700;
}

/* Modal footer */
.forgot-password-modal .modal-footer,
.recovery-success-modal .modal-footer {
  padding: 20px;
  border-top: 2px solid var(--line, #333);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-secondary {
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text, #fff);
  border: 1px solid var(--line, #333);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-primary {
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--accent, #4caf50);
  color: white;
  border: none;
}

.btn-primary:hover {
  background: #45a049;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Success message */
.success-message {
  text-align: center;
}

.success-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.success-message p {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 12px;
  color: var(--text, #fff);
}

.success-message strong {
  color: var(--accent, #4caf50);
  font-size: 16px;
}

.success-hint {
  font-size: 13px;
  color: var(--muted, #999);
  margin-top: 16px;
}

/* Mobile */
@media (max-width: 768px) {
  .forgot-password-modal,
  .recovery-success-modal {
    width: 95%;
  }

  .forgot-password-modal .modal-header h2,
  .recovery-success-modal .modal-header h2 {
    font-size: 18px;
  }
}
