* { box-sizing: border-box; }

html { background: #080b10; }

body {
  margin: 0;
  background: radial-gradient(circle at top left, rgba(80, 106, 148, 0.22), transparent 30%), #080b10;
  color: #f4efe7;
  font-family: "Times New Roman", Times, serif;
}

a { color: inherit; text-decoration: none; }

button, input, select {
  font-family: "Times New Roman", Times, serif;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-card {
  width: 100%;
  max-width: 460px;
  background: rgba(18, 25, 34, 0.94);
  border: 1px solid #34465f;
  border-radius: 22px;
  padding: 36px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
}

.login-card h1 {
  font-size: 52px;
  line-height: 1;
  margin: 0 0 12px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  border-right: 1px solid #223145;
  background: rgba(11, 15, 20, 0.88);
  padding: 30px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-size: 38px;
  font-weight: 700;
  margin-bottom: 6px;
}

.brand-subtitle {
  color: #b7c6d9;
  margin-bottom: 30px;
  font-size: 17px;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav a, .nav form button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #f4efe7;
  border: 1px solid #2b3d55;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 18px;
}

.nav a:hover, .nav form button:hover {
  background: #121922;
}

.main { padding: 36px; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 28px;
}

.eyebrow {
  color: #b7c6d9;
  font-size: 17px;
  margin: 0 0 8px;
}

h1 {
  font-size: 46px;
  line-height: 1.05;
  margin: 0 0 10px;
}

h2 {
  font-size: 29px;
  margin: 0 0 10px;
}

p { font-size: 18px; }

.muted { color: #b7c6d9; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.grid.two {
  grid-template-columns: minmax(300px, 420px) 1fr;
}

.card {
  background: rgba(18, 25, 34, 0.94);
  border: 1px solid #2b3d55;
  border-radius: 22px;
  padding: 26px;
  min-height: 145px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.22);
}

.input, .select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #33465f;
  background: #080b10;
  color: #f4efe7;
  margin-top: 6px;
  font-size: 17px;
}

.button {
  border: 0;
  background: #f4efe7;
  color: #080b10;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  font-size: 17px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.table-card { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  border-bottom: 1px solid #223145;
  padding: 14px;
  text-align: left;
  font-size: 17px;
}

.table th {
  color: #b7c6d9;
  font-weight: 400;
}

.badge {
  display: inline-block;
  border: 1px solid #34465f;
  border-radius: 999px;
  padding: 5px 10px;
  color: #d9e5f4;
}

.flash-wrap { margin-bottom: 18px; }

.flash {
  border: 1px solid #34465f;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: #121922;
}

.flash.error {
  border-color: #8a3d3d;
  color: #ffb0b0;
}

.flash.success {
  border-color: #3d8a61;
  color: #b9ffd8;
}

@media (max-width: 840px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .grid.two { grid-template-columns: 1fr; }
  .main { padding: 22px; }
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.use-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.input.compact,
.select.compact {
  width: 100px;
  min-width: 90px;
  margin-top: 0;
  padding: 8px 10px;
}

.compact-button {
  padding: 9px 12px;
}

@media (max-width: 840px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .use-form {
    display: grid;
  }

  .input.compact,
  .select.compact {
    width: 100%;
  }
}

.stat {
  font-size: 44px;
  font-weight: 700;
  margin-top: 14px;
}

.recipe-grid {
  display: grid;
  gap: 16px;
}

.recipe-card {
  display: block;
  border-radius: 22px;
  padding: 24px;
  border: 2px solid #2b3d55;
  background: rgba(18, 25, 34, 0.94);
}

.recipe-card.can-make {
  border-color: #1f8f4d;
  background: rgba(20, 74, 43, 0.45);
}

.recipe-card.not-enough {
  border-color: #9c2d2d;
  background: rgba(86, 24, 24, 0.45);
}

.recipe-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.status-pill {
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.green {
  background: #1f8f4d;
  color: white;
}

.status-pill.red {
  background: #9c2d2d;
  color: white;
}

.ingredient-list {
  margin-top: 14px;
  font-size: 18px;
  display: grid;
  gap: 6px;
}

.button.danger {
  background: #9c2d2d;
  color: white;
}

.topbar .status-pill {
  align-self: center;
}

.input.compact-wide,
.select.compact-wide {
  width: 160px;
  min-width: 140px;
  margin-top: 0;
  padding: 8px 10px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button.secondary {
  background: transparent;
  color: #f4efe7;
  border: 1px solid #34465f;
}

@media (max-width: 840px) {
  .input.compact-wide,
  .select.compact-wide {
    width: 100%;
  }

  .row-actions {
    display: grid;
  }
}

.brand {
  display: block;
  color: #f4efe7;
}

.nav-group {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.nav-label {
  color: #7f93ad;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 4px 0 2px;
}

.home-section {
  margin-bottom: 34px;
}

.home-section h2 {
  font-size: 30px;
  margin-bottom: 14px;
  border-bottom: 1px solid #223145;
  padding-bottom: 10px;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.tile {
  background: rgba(18, 25, 34, 0.94);
  border: 1px solid #2b3d55;
  border-radius: 18px;
  padding: 22px;
  min-height: 90px;
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
}

.tile:hover {
  border-color: #6f8db5;
  background: rgba(25, 35, 48, 0.96);
}

.card {
  min-height: 110px;
}

.grid {
  align-items: start;
}

.sidebar {
  width: 260px;
}

.shell {
  grid-template-columns: 260px 1fr;
}

@media (max-width: 840px) {
  .tile {
    min-height: 72px;
    font-size: 23px;
  }
}

:root {
  --bg: #09070d;
  --panel: #15101b;
  --panel-2: #1d1424;
  --border: #4a324f;
  --text: #fff6ee;
  --muted: #d7b8d6;
  --pink: #ff79c8;
  --pink-dark: #7f2c61;
  --yellow: #ffe66d;
  --yellow-dark: #806f23;
  --danger: #a32f4f;
  --green: #28a866;
}

html {
  background: var(--bg);
}

body {
  background:
    radial-gradient(circle at top left, rgba(255, 121, 200, 0.20), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 230, 109, 0.13), transparent 22%),
    var(--bg);
  color: var(--text);
}

.sidebar {
  background: rgba(9, 7, 13, 0.94);
  border-right: 1px solid var(--border);
}

.brand {
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--pink-dark);
}

.user-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
  background: linear-gradient(135deg, rgba(255, 121, 200, 0.18), rgba(255, 230, 109, 0.08));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  margin: 18px 0 26px;
}

.kuromi-img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.user-label {
  color: var(--muted);
  font-size: 14px;
}

.user-name {
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}

.user-role {
  color: var(--yellow);
  font-size: 13px;
  letter-spacing: 0.08em;
  margin-top: 3px;
}

.nav-label {
  color: var(--pink);
}

.nav a,
.nav form button {
  border-color: var(--border);
}

.nav a:hover,
.nav form button:hover {
  background: var(--panel-2);
  border-color: var(--pink);
}

.card,
.tile,
.recipe-card,
.login-card {
  background: rgba(21, 16, 27, 0.95);
  border-color: var(--border);
}

.card:hover,
.tile:hover {
  border-color: var(--pink);
}

.tile {
  background: linear-gradient(135deg, rgba(255, 121, 200, 0.10), rgba(255, 230, 109, 0.05));
}

.input,
.select {
  background: #08060c;
  color: var(--text);
  border-color: var(--border);
}

.input:focus,
.select:focus {
  outline: 2px solid var(--pink);
  border-color: var(--pink);
}

.button {
  background: var(--yellow);
  color: #120b16;
}

.button:hover {
  filter: brightness(1.05);
}

.button.secondary {
  color: var(--text);
  border-color: var(--pink-dark);
}

.status-pill.green {
  background: var(--green);
}

.status-pill.red,
.button.danger {
  background: var(--danger);
}

.badge {
  border-color: var(--pink-dark);
  color: var(--yellow);
}

.table th {
  color: var(--muted);
}

.table th,
.table td {
  border-bottom-color: #35223b;
}

.home-section h2 {
  border-bottom-color: var(--border);
}

.flash {
  background: var(--panel);
  border-color: var(--border);
}

.logo-link {
  display: block;
  margin-bottom: 18px;
}

.brand-logo-img {
  width: 178px;
  max-width: 100%;
  height: auto;
  display: block;
  filter:
    drop-shadow(0 0 8px rgba(255, 230, 109, 0.35))
    drop-shadow(2px 2px 0 rgba(255, 121, 200, 0.38));
}

@media (max-width: 840px) {
  .brand-logo-img {
    width: 150px;
  }
}

.game-card {
  padding: 0;
  overflow: hidden;
}

#game {
  width: 100%;
  height: 720px;
  min-height: 520px;
  background: #000;
  border-radius: 22px;
  overflow: hidden;
}

@media (max-width: 840px) {
  #game {
    height: 520px;
  }
}

.game-frame {
  width: 100%;
  height: 760px;
  border: 0;
  display: block;
  background: #000;
  border-radius: 22px;
}

@media (max-width: 840px) {
  .game-frame {
    height: 560px;
  }
}

.game-card {
  padding: 0;
  overflow: hidden;
}

.game-frame {
  width: 100%;
  height: calc(100vh - 150px);
  min-height: 720px;
  border: 0;
  display: block;
  background: #000;
  border-radius: 22px;
}

@media (max-width: 840px) {
  .game-frame {
    height: 560px;
    min-height: 560px;
  }
}

.game-topbar {
  margin-bottom: 18px;
}

.mobile-controls {
  display: none;
}

@media (max-width: 900px), (pointer: coarse) {
  .game-frame {
    height: 54vh;
    min-height: 360px;
  }

  .mobile-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-top: 18px;
    user-select: none;
    touch-action: none;
  }

  .dpad {
    display: grid;
    grid-template-areas:
      ". up ."
      "left . right"
      ". down .";
    gap: 10px;
    justify-content: start;
    align-content: center;
  }

  .control-btn {
    border: 1px solid var(--border);
    background: rgba(255, 121, 200, 0.16);
    color: var(--text);
    border-radius: 18px;
    min-width: 64px;
    min-height: 58px;
    font-size: 24px;
    font-weight: 700;
  }

  .control-btn:active {
    background: var(--yellow);
    color: #120b16;
  }

  .up { grid-area: up; }
  .left { grid-area: left; }
  .right { grid-area: right; }
  .down { grid-area: down; }

  .action-pad {
    display: grid;
    grid-template-columns: repeat(2, minmax(72px, 1fr));
    gap: 10px;
    align-content: center;
  }

  .action {
    min-height: 72px;
    font-size: 30px;
    background: rgba(255, 230, 109, 0.18);
  }

  .small-action,
  .menu-action {
    font-size: 18px;
  }
}

/* Final mobile override */
@media (max-width: 900px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .shell {
    display: block !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
  }

  .sidebar {
    width: 100% !important;
    height: auto !important;
    position: relative !important;
    border-right: 0 !important;
    border-bottom: 1px solid var(--border);
    padding: 18px 14px !important;
  }

  .logo-link {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
  }

  .brand-logo-img {
    width: 150px !important;
    margin: 0 auto 8px !important;
  }

  .user-card {
    max-width: 360px;
    margin: 10px auto 18px !important;
    grid-template-columns: 48px 1fr;
  }

  .nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .nav-group {
    margin-bottom: 10px !important;
  }

  .nav-label {
    margin-top: 10px;
  }

  .nav a,
  .nav form button {
    font-size: 18px;
    padding: 12px 14px;
  }

  .main {
    width: 100% !important;
    padding: 18px 14px 120px !important;
  }

  h1 {
    font-size: clamp(42px, 13vw, 62px) !important;
    line-height: 1 !important;
  }

  h2 {
    font-size: 30px !important;
  }

  .tile-grid,
  .grid,
  .grid.two {
    grid-template-columns: 1fr !important;
  }

  .tile,
  .card {
    width: 100% !important;
  }
}

.game-card {
  padding: 0 !important;
  overflow: hidden;
}

.game-frame {
  width: 100%;
  height: calc(100vh - 160px);
  min-height: 640px;
  border: 0;
  display: block;
  background: #000;
  border-radius: 22px;
}

.mobile-controls {
  display: none;
}

@media (max-width: 900px), (pointer: coarse) {
  .game-frame {
    height: 44vh !important;
    min-height: 300px !important;
    border-radius: 18px !important;
  }

  .mobile-controls {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
    user-select: none;
    touch-action: none;
  }

  .dpad {
    display: grid;
    grid-template-areas:
      ". up ."
      "left . right"
      ". down .";
    gap: 10px;
    justify-content: start;
    align-content: center;
  }

  .control-btn {
    border: 1px solid var(--border);
    background: rgba(255, 121, 200, 0.18);
    color: var(--text);
    border-radius: 18px;
    min-width: 64px;
    min-height: 60px;
    font-size: 24px;
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
    touch-action: none;
  }

  .control-btn:active {
    background: var(--yellow);
    color: #120b16;
  }

  .up { grid-area: up; }
  .left { grid-area: left; }
  .right { grid-area: right; }
  .down { grid-area: down; }

  .action-pad {
    display: grid;
    grid-template-columns: repeat(2, minmax(72px, 1fr));
    gap: 10px;
    align-content: center;
  }

  .action {
    min-height: 72px;
    font-size: 32px;
    background: rgba(255, 230, 109, 0.18);
  }

  .small-action,
  .menu-action {
    font-size: 18px;
  }
}

@media (max-width: 900px) {
  body.game-body .sidebar {
    display: none !important;
  }

  body.game-body .shell {
    display: block !important;
  }

  body.game-body .main {
    width: 100% !important;
    padding: 12px 10px 160px !important;
  }

  body.game-body .topbar {
    margin-bottom: 12px !important;
  }

  body.game-body h1 {
    font-size: 40px !important;
    line-height: 0.95 !important;
  }

  body.game-body .game-frame {
    width: 100% !important;
    height: 42vh !important;
    min-height: 300px !important;
    border-radius: 18px !important;
  }

  body.game-body .mobile-controls {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
    touch-action: none;
    user-select: none;
  }

  body.game-body .control-btn {
    border: 1px solid var(--border);
    background: rgba(255, 121, 200, 0.20);
    color: var(--text);
    border-radius: 18px;
    min-width: 64px;
    min-height: 60px;
    font-size: 24px;
    font-weight: 700;
    touch-action: none;
  }

  body.game-body .control-btn.pressed,
  body.game-body .control-btn:active {
    background: var(--yellow);
    color: #120b16;
  }
}
