/* Beaks Arcade — stippled, moody, pink + ink */
:root {
  --bg: #1a1620;
  --bg-2: #25202d;
  --ink: #eae3d2;
  --pink: #e98ab8;
  --pink-2: #f4b6d2;
  --green: #6aa84f;
  --accent: #ffd166;
  --danger: #ef476f;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* faux stipple texture */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  z-index: 0;
}

.screen {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  flex-direction: column;
  padding: 16px;
  z-index: 1;
}
.screen.active { display: flex; }

/* ============ LOGIN ============ */
#screen-login .card {
  background: var(--bg-2);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  padding: 32px 28px;
  text-align: center;
  width: min(360px, 92vw);
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
h1 {
  font-size: 28px; margin: 0 0 4px;
  letter-spacing: 2px;
}
h1 span { color: var(--pink); margin-left: 8px; }
.sub { opacity: .6; margin: 0 0 22px; font-size: 13px; }
.hint { opacity: .4; font-size: 11px; margin: 10px 0 0; }

input[type=text] {
  width: 100%;
  background: var(--bg);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--ink);
  padding: 12px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
}
input[type=text]:focus { border-color: var(--pink); }

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  letter-spacing: 1px;
  transition: transform .08s, background .15s;
}
button:active { transform: translateY(1px); }
.primary {
  background: var(--pink); color: #1a0e16;
  font-weight: 700; width: 100%;
}
.primary:hover { background: var(--pink-2); }
.ghost {
  background: transparent; color: var(--ink);
  border: 1px solid rgba(255,255,255,.15);
}
.ghost:hover { background: rgba(255,255,255,.05); }

/* ============ SELECT ============ */
.select-head { text-align: center; margin-bottom: 18px; }
.select-head h2 { margin: 0; letter-spacing: 2px; }
.who { opacity: .6; margin: 4px 0 0; font-size: 12px; }
.who span { color: var(--accent); }

.roster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  width: min(720px, 96vw);
  margin-bottom: 18px;
}
.char {
  background: var(--bg-2);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  transition: border-color .15s, transform .15s;
}
.char:hover { border-color: var(--pink); transform: translateY(-2px); }
.char h3 { margin: 10px 0 2px; }
.char p { margin: 2px 0; font-size: 12px; opacity: .7; }
.char .mode { color: var(--accent); letter-spacing: 1px; margin-top: 8px; }
.char .best { opacity: .6; }
.char .play { width: 100%; margin-top: 12px; background: var(--pink); color: #1a0e16; font-weight: 700; }

.frame {
  position: relative;
  width: 100%; aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: #2d2735;
  display: flex; align-items: center; justify-content: center;
}
.frame img { width: 100%; height: 100%; object-fit: cover; image-rendering: auto; display: block; }
.frame img:not([src]), .frame img[src=""] { display: none; }
.upload-btn {
  position: absolute; right: 8px; bottom: 8px;
  width: 32px; height: 32px; padding: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff; font-size: 18px; line-height: 1;
  border: 1px solid rgba(255,255,255,0.2);
}
.upload-btn:hover { background: var(--pink); color: #1a0e16; }
.fallback {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  font-weight: 800; letter-spacing: 3px;
}
.bird-fb { background: var(--pink); color: #1a0e16; }
.gecko-fb { background: var(--green); color: #0e1a0e; }

#btn-logout { margin-top: 4px; }

/* ============ GAME ============ */
#screen-game { padding: 0; }
.hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  z-index: 5;
  background: linear-gradient(to bottom, rgba(0,0,0,.5), transparent);
}
.score {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px;
}
.score .label { opacity: .5; font-size: 10px; letter-spacing: 1px; }
.score #score { color: var(--accent); font-weight: 800; min-width: 32px; text-align: center; }
.score #best { color: var(--pink); min-width: 32px; text-align: center; }

#canvas {
  width: min(420px, 100vw);
  height: min(720px, 100vh);
  max-height: 100vh;
  background: #0f0c14;
  display: block;
  touch-action: none;
}

.overlay {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(10,8,14,.6);
  backdrop-filter: blur(6px);
  z-index: 4;
}
.overlay.show { display: flex; }
.overlay-card {
  background: var(--bg-2);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  padding: 24px 28px;
  text-align: center;
  width: min(320px, 86vw);
}
.overlay-card h2 { margin: 0 0 4px; letter-spacing: 2px; }
.overlay-card p { margin: 0 0 18px; opacity: .6; font-size: 12px; }

@media (max-width: 640px) {
  .screen {
    justify-content: flex-start;
    overflow-y: auto;
    padding: 12px;
  }

  #screen-login,
  #screen-game {
    justify-content: center;
    overflow: hidden;
  }

  .select-head {
    margin: 10px 0 12px;
  }

  .select-head h2 {
    font-size: 24px;
    line-height: 1.15;
  }

  .roster {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    margin-bottom: 12px;
  }

  .char {
    padding: 10px;
    border-radius: 12px;
  }

  .char h3 {
    font-size: 15px;
    line-height: 1.15;
    margin-top: 8px;
  }

  .char p {
    font-size: 10px;
    line-height: 1.25;
  }

  .char .mode {
    margin-top: 6px;
    letter-spacing: 0;
  }

  .char .play {
    margin-top: 8px;
    padding: 10px;
  }

  .frame {
    border-radius: 10px;
  }

  .upload-btn {
    right: 6px;
    bottom: 6px;
    width: 30px;
    height: 30px;
  }

  #btn-logout {
    margin-bottom: 12px;
  }

  .hud {
    padding: max(10px, env(safe-area-inset-top)) 10px 10px;
  }

  .hud .ghost {
    padding: 10px 12px;
    font-size: 12px;
  }

  .score {
    gap: 4px;
    font-size: 12px;
  }

  .score .label {
    font-size: 9px;
  }

  #canvas {
    width: min(100vw, calc(100vh * 0.5834));
    height: min(100vh, calc(100vw * 1.7143));
  }

  .overlay-card {
    width: min(300px, 88vw);
    padding: 22px;
  }
}

@media (max-width: 360px) {
  .select-head h2 {
    font-size: 21px;
  }

  .char {
    padding: 8px;
  }

  .char h3 {
    font-size: 13px;
  }

  .char p {
    font-size: 9px;
  }
}
