/* ============================================================
   Quoridor - Classic Wood Theme
   ============================================================ */

/* ---------- reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Georgia', 'Times New Roman', serif;
  color: #3e2c1a;
  background:
    radial-gradient(ellipse at 50% 0%, #5c8a50 0%, #2d5a27 60%, #1a3c12 100%);
  background-attachment: fixed;
}

/* ---------- lobby ---------- */
#lobby {
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; min-height: 100vh; padding: 2rem 2rem 4rem;
}
#lobby h1 { font-size: 3rem; color: #f5e6c8; text-shadow: 2px 2px 6px rgba(0,0,0,.5); margin-bottom: .25rem; }
#lobby .subtitle { color: #d4c4a0; margin-bottom: 2rem; font-style: italic; }

.lobby-box {
  background: linear-gradient(145deg, #d2b48c, #c49a6c); border-radius: 12px;
  padding: 2rem; box-shadow: 0 6px 24px rgba(0,0,0,.4);
  display: flex; flex-direction: column; gap: 1rem; width: 320px; text-align: center;
}
.divider { display: flex; align-items: center; gap: .5rem; color: #6b4c2e; font-style: italic; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: #6b4c2e; }

#inp-code {
  padding: .6rem; border: 2px solid #8b6d4c; border-radius: 6px;
  text-align: center; font-size: 1.2rem; letter-spacing: .15em; background: #faf3e3; width: 100%;
}
.msg { margin-top: 1rem; padding: .6rem 1rem; border-radius: 6px; }
.msg.error { background: #f8d7da; color: #842029; }
.msg.success { background: #d1e7dd; color: #0f5132; }
.hidden { display: none !important; }

/* ---------- games list ---------- */
#games-section { margin-top: 2rem; width: 100%; max-width: 560px; }
#games-section h2 { color: #f5e6c8; font-size: 1.3rem; margin-bottom: .75rem; text-shadow: 1px 1px 4px rgba(0,0,0,.4); }
#games-list { display: flex; flex-direction: column; gap: .5rem; }
.games-loading, .games-empty { color: #d4c4a0; font-style: italic; text-align: center; }
.game-row {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(145deg, #d2b48c, #c49a6c); border-radius: 8px;
  padding: .6rem 1rem; box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.game-info { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; flex: 1; min-width: 0; }
.game-code { font-family: 'Courier New', monospace; font-weight: bold; font-size: .95rem; background: #4a3420; color: #f5e6c8; padding: 1px 8px; border-radius: 4px; letter-spacing: .08em; }
.game-status { font-weight: bold; font-size: .85rem; }
.game-detail { font-size: .78rem; color: #5a3e28; }
.game-actions { display: flex; gap: .4rem; margin-left: .6rem; flex-shrink: 0; }

/* ---------- buttons ---------- */
.btn {
  cursor: pointer; border: none; border-radius: 6px; padding: .65rem 1.4rem;
  font-size: 1rem; font-family: inherit; transition: transform .1s, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(145deg, #6b4c2e, #4a3420); color: #f5e6c8; box-shadow: 0 3px 8px rgba(0,0,0,.35); }
.btn-primary:hover { box-shadow: 0 4px 14px rgba(0,0,0,.45); }
.btn-secondary { background: linear-gradient(145deg, #c49a6c, #a07848); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.btn-small { padding: .4rem .9rem; font-size: .85rem; }

/* ---------- game layout ---------- */
#game-root {
  display: flex; flex-direction: column; align-items: center;
  padding: 1rem; min-height: 100vh;
}

#game-main {
  display: flex; gap: 1rem; align-items: flex-start;
}

#board-column {
  display: flex; flex-direction: column; align-items: stretch;
}

/* top bar */
#top-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(145deg, #d2b48c, #c49a6c);
  border-radius: 10px 10px 0 0; padding: .6rem 1.2rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.player-info { display: flex; align-items: center; gap: .4rem; font-size: .95rem; font-weight: bold; }
.player-info.active-turn { background: rgba(255,220,80,0.35); border-radius: 6px; padding: 2px 8px; box-shadow: 0 0 8px rgba(255,200,0,0.5), inset 0 0 4px rgba(255,220,80,0.3); }
.pawn-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #4a3420; }
.p1-dot { background: #f5e6c8; }
.p2-dot { background: #4a3420; }
.wall-count { background: #4a3420; color: #f5e6c8; font-size: 1.1rem; padding: 1px 6px; border-radius: 4px; margin-left: 2px; }
.clock {
  font-family: 'Courier New', monospace; font-size: .9rem; font-weight: bold;
  background: #3e2c1a; color: #f5e6c8; padding: 2px 8px; border-radius: 4px;
  margin-left: 4px; min-width: 48px; text-align: center; display: inline-block;
}
.clock.urgent { background: #b22222; color: #fff; }

/* status */
#status-line {
  text-align: center; padding: .35rem; background: #c49a6c; color: #fff; font-size: .9rem;
}

/* board */
#board-wrap {
  background: linear-gradient(145deg, #d2b48c, #c49a6c);
  padding: 10px; border-radius: 0 0 10px 10px; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
#board-canvas { display: block; }

/* hamburger menu */
#hamburger-wrap { position: relative; }
.hamburger {
  background: none; border: none; cursor: pointer; padding: 4px 6px;
  display: flex; flex-direction: column; gap: 4px;
}
.hamburger span {
  display: block; width: 22px; height: 3px; background: #4a3420; border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
#hamburger-menu {
  position: absolute; top: 100%; left: 0; margin-top: 6px; z-index: 50;
  background: linear-gradient(145deg, #d2b48c, #c49a6c);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.4);
  min-width: 180px; padding: .35rem 0; overflow: hidden;
}
.menu-item {
  display: block; width: 100%; text-align: left; padding: .55rem 1rem;
  background: none; border: none; font-family: inherit; font-size: .9rem;
  color: #3e2c1a; cursor: pointer; transition: background .1s;
}
.menu-item:hover { background: rgba(255,255,255,.2); }
.menu-danger { color: #b22222; }

/* hidden share-link input (used only for clipboard copy) */
#share-link { position: absolute; left: -9999px; }

/* ---------- sidebar ---------- */
#sidebar {
  width: 260px; display: flex; flex-direction: column; gap: 1rem;
  flex-shrink: 0;
}

/* saves */
#saves-section {
  background: linear-gradient(145deg, #d2b48c, #c49a6c);
  border-radius: 10px; padding: .8rem; box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
#saves-section h3 { font-size: .95rem; margin-bottom: .5rem; color: #3e2c1a; }
#saves-list { display: flex; flex-direction: column; gap: .35rem; max-height: 200px; overflow-y: auto; }
.saves-empty { color: #6b4c2e; font-style: italic; font-size: .85rem; }
.save-row {
  display: flex; align-items: center; gap: .5rem;
  background: rgba(255,255,255,.15); border-radius: 6px; padding: .3rem .6rem; font-size: .82rem;
}
.save-label { flex: 1; font-weight: bold; color: #3e2c1a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-time { color: #5a3e28; font-size: .75rem; flex-shrink: 0; }

/* chat */
#chat-section {
  background: linear-gradient(145deg, #d2b48c, #c49a6c);
  border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,.3); overflow: hidden;
}
#chat-section h3 { font-size: .95rem; padding: .6rem .8rem .2rem; color: #3e2c1a; display: flex; justify-content: space-between; align-items: center; }
#chat-toggle { cursor: pointer; font-size: .75rem; color: #6b4c2e; user-select: none; }
#chat-messages { height: 200px; overflow-y: auto; padding: .4rem .8rem; font-size: .82rem; line-height: 1.5; }
.chat-line { word-break: break-word; }
.chat-sender { font-weight: bold; color: #4a3420; }
.chat-text { color: #3e2c1a; }
#chat-input-row { display: flex; border-top: 1px solid #a07848; }
#chat-input {
  flex: 1; padding: .5rem .8rem; border: none; background: #faf3e3;
  font-family: inherit; font-size: .85rem; outline: none;
}
#chat-input::placeholder { color: #a09070; }
#chat-input-row .btn { border-radius: 0 0 10px 0; }

/* toast */
#toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
  background: #4a3420; color: #f5e6c8; padding: .6rem 1.4rem; border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,.5); z-index: 100; font-size: .9rem; transition: opacity .3s;
}

/* modals */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-content {
  background: linear-gradient(145deg, #d2b48c, #c49a6c); border-radius: 12px;
  padding: 2rem; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,.5); min-width: 280px;
}
.modal-content h2 { margin-bottom: 1rem; }
.modal-content .btn { margin: .3rem; }

/* responsive: stack sidebar below on narrow screens */
@media (max-width: 900px) {
  #game-main { flex-direction: column; align-items: center; }
  #sidebar { width: 100%; max-width: 560px; }
}

/* ---------- user bar ---------- */
#user-bar {
  margin-bottom: 1rem; text-align: center;
}
.user-greeting {
  color: #f5e6c8; font-size: .95rem;
}
#auth-box input {
  padding: .5rem; border: 2px solid #8b6d4c; border-radius: 6px;
  font-size: 1rem; background: #faf3e3; width: 100%; text-align: center;
}

/* ---------- lobby user menu (upper right hamburger) ---------- */
#user-menu-wrap {
  position: fixed; top: 1rem; right: 1rem; z-index: 60;
}
#user-menu {
  position: absolute; top: 100%; right: 0; margin-top: 6px;
  background: linear-gradient(145deg, #d2b48c, #c49a6c);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.4);
  min-width: 200px; padding: .35rem 0; overflow: hidden;
}
.menu-label {
  padding: .5rem 1rem; font-size: .85rem; color: #3e2c1a; border-bottom: 1px solid rgba(0,0,0,.1);
}
.menu-input {
  display: block; width: calc(100% - 1.6rem); margin: .4rem .8rem;
  padding: .4rem .6rem; border: 2px solid #8b6d4c; border-radius: 4px;
  font-size: .85rem; background: #faf3e3; font-family: inherit;
}

/* ---------- my other games panel ---------- */
#my-games-section {
  background: linear-gradient(145deg, #d2b48c, #c49a6c);
  border-radius: 10px; padding: .8rem; box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
#my-games-section h3 { font-size: .95rem; margin-bottom: .5rem; color: #3e2c1a; }
#my-games-list { display: flex; flex-direction: column; gap: .35rem; max-height: 180px; overflow-y: auto; }
.my-game-row {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.15); border-radius: 6px; padding: .3rem .6rem; font-size: .82rem;
}
.my-game-status { font-size: .78rem; color: #5a3e28; flex: 1; text-align: center; }
.my-game-code { font-family: 'Courier New', monospace; font-weight: bold; color: #3e2c1a; }

/* ---------- create game settings ---------- */
.setting-row {
  display: block; padding: .5rem 0; font-size: .95rem; color: #3e2c1a;
}
.setting-row select {
  padding: .3rem .5rem; border: 2px solid #8b6d4c; border-radius: 4px;
  background: #faf3e3; font-family: inherit; font-size: .9rem; margin-left: .4rem;
}
.modal-content .btn { margin: .3rem; }

/* ---------- share section (sidebar) ---------- */
#share-section {
  background: linear-gradient(145deg, #d2b48c, #c49a6c);
  border-radius: 10px; padding: .6rem .8rem; box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.share-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .4rem;
}
.share-header span { font-size: .85rem; font-weight: bold; color: #3e2c1a; }
.share-input {
  display: block; width: 100%; padding: .3rem .5rem; border: 2px solid #8b6d4c; border-radius: 4px;
  font-size: .75rem; background: #faf3e3; font-family: inherit;
}

/* ---------- start game panel ---------- */
#start-section {
  background: linear-gradient(145deg, #d2b48c, #c49a6c);
  border-radius: 10px; padding: .8rem; box-shadow: 0 4px 12px rgba(0,0,0,.3);
  text-align: center;
}

/* ---------- past games & my history ---------- */
#past-games-section, #my-history-section {
  margin-top: 2rem; width: 100%; max-width: 560px;
}
#past-games-section h2, #my-history-section h2 {
  color: #f5e6c8; font-size: 1.3rem; margin-bottom: .75rem; text-shadow: 1px 1px 4px rgba(0,0,0,.4);
}
