/* 0.3.1 – Mobile header and complete 2×5 raw material overview. No horizontal scrolling. */

/* Tablets and desktops: all ten resources fit without scrolling too. */
@media (min-width:761px) {
  .resource-strip { display:grid; grid-template-columns:180px minmax(0,1fr); }
  .resource-strip-head { min-width:0; }
  .resource-rail {
    display:grid; grid-template-columns:repeat(10,minmax(0,1fr)); 
    align-items:stretch; gap:5px; overflow:visible; min-width:0;
    padding:4px 0;
  }
  .resource-tile {
    min-width:0; width:100%; flex:none;
    display:flex; flex-direction:column; align-items:center; 
    justify-content:center; gap:3px; padding:5px 3px;
    text-align:center;
  }
  .resource-tile .res-data { min-width:0; width:100%; align-items:center; }
  .resource-tile .res-symbol { font-size:18px; min-width:0; }
  .resource-tile .res-name { font-size:10px; width:100%; text-overflow:ellipsis; }
  .resource-tile .res-amount { font-size:clamp(10px,1vw,16px); }
  .resource-tile .res-rate { font-size:clamp(9px,.85vw,12px); }
}
@media (min-width:761px) and (max-width:1360px) {
  .resource-strip {
    --resource-strip-height:150px; height:var(--resource-strip-height);min-height:var(--resource-strip-height);
    grid-template-columns:170px minmax(0,1fr); padding:7px 12px;
  }
  .resource-rail {
    grid-template-columns:repeat(5,minmax(0,1fr));
    grid-template-rows:repeat(2,minmax(0,1fr));gap:5px;
  }
  .resource-tile { flex-direction:row;justify-content:center;gap:7px; }
  .resource-tile .res-data { width:auto;align-items:flex-start;text-align:left; }
  .resource-tile .res-amount { font-size:13px; }
}

/* Exact 5 × 2 on handheld phones, no drag/scroll required. */
@media (max-width:760px) {
  :root {
    --resource-strip-height:194px;
    --space-header-height:88px;
  }
  .topbar {
    display:grid;grid-template-columns:minmax(0,1fr) auto;
    grid-template-rows:45px 30px;align-items:center;
    gap:0 6px; height:var(--space-header-height);
    min-height:var(--space-header-height);padding:4px 8px 7px;
  }
  .top-logo {
    grid-row:1;grid-column:1;min-width:0;max-width:100%;
    display:flex;align-items:center;justify-content:flex-start;gap:7px;
    overflow:hidden;
  }
  .top-logo .emblem {
    width:34px;height:34px;font-size:23px;border-radius:9px;flex:none;
  }
  .top-logo > span:last-child { min-width:0;display:block; }
  .top-logo strong {
    display:block;font-size:clamp(11px,3.25vw,13px);
    font-weight:850;letter-spacing:.015em;line-height:1.03;
    text-align:left;white-space:normal;
  }
  .top-logo strong b { display:block;font-size:1.04em;letter-spacing:.015em; }
  .top-logo small { display:none; }
  .top-actions {
    grid-column:2;grid-row:1;min-width:0;justify-self:end;
    display:flex;gap:3px;align-items:center;
  }
  .top-actions .icon-btn {
    display:grid;place-items:center;width:30px;height:32px;min-width:30px;
    border-radius:8px;font-size:17px;flex:none;
  }
  .top-actions .help-circle { width:30px;min-width:30px;height:32px; }
  .top-actions .profile-btn {
    display:grid;place-items:center;width:31px;min-width:31px;height:32px;
    padding:0;font-size:16px;
  }
  .top-actions .profile-btn span { display:none; }
  .top-resources {
    grid-column:1/-1;grid-row:2;width:100%;
    display:grid;grid-template-columns:repeat(4,minmax(0,1fr));
    gap:3px;justify-content:stretch;align-items:stretch;
    min-width:0;max-width:100%;padding:0;
  }
  .top-resources .top-chip,
  .top-resources .top-chip:nth-child(2),
  .top-resources .top-chip:nth-child(4) {
    display:flex;align-items:center;justify-content:center;gap:4px;
    min-width:0;width:100%;height:30px;padding:1px 4px;
    border:1px solid #6b618c75;background:#161d37bf;
    border-radius:6px;overflow:hidden;
  }
  .top-resources .top-chip > span { font-size:12px;flex:none; }
  .top-resources .top-chip > div { min-width:0;display:flex;gap:4px;align-items:baseline; }
  .top-resources .top-chip small {
    font-size:8px;white-space:nowrap;letter-spacing:0;
  }
  .top-resources .top-chip strong {
    font-size:11px;white-space:nowrap;min-width:0;
    overflow:hidden;text-overflow:ellipsis;
  }

  .resource-strip {
    display:flex;flex-direction:column;
    --resource-strip-height:inherit;
    width:100%;height:var(--resource-strip-height);
    min-height:var(--resource-strip-height);
    gap:5px;padding:6px 6px 7px;overflow:hidden;
  }
  .resource-strip-head {
    flex:none;min-height:31px;height:31px;display:flex;
    flex-direction:row;align-items:center;justify-content:space-between;
    gap:5px;min-width:0;
  }
  .strip-heading { flex:1;min-width:0;gap:5px; }
  .strip-heading > span:last-child { min-width:0; }
  .strip-heading .resource-orbit { font-size:18px;flex:none; }
  .strip-heading strong { font-size:10px;letter-spacing:.045em;white-space:nowrap; }
  .strip-heading small { display:block;max-width:100%;font-size:8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
  .resource-scope { width:auto;min-width:112px;flex:none;gap:1px;padding:2px; }
  .resource-scope button { font-size:10px;padding:6px 7px; }
  .resource-expand {
    position:static;flex:none;display:grid;place-items:center;
    min-width:29px;height:29px;padding:2px 5px;
    font-size:16px;line-height:1;
  }
  .resource-expand span { display:none; }
  .resource-rail {
    flex:1;min-height:0;min-width:0;width:100%;
    display:grid;grid-template-columns:repeat(5,minmax(0,1fr));
    grid-template-rows:repeat(2,minmax(0,1fr));
    gap:4px;overflow:hidden;
    padding:0;margin:0;
    scroll-snap-type:none;touch-action:auto;
  }
  .resource-tile {
    display:flex;flex-direction:column;flex:initial;
    align-items:center;justify-content:center;
    min-width:0;width:100%;height:100%;
    padding:4px 1px 3px;gap:2px;
    text-align:center;border-radius:8px;
    box-shadow:inset 0 1px #ffffff18,0 2px 7px #0007;
  }
  .resource-tile .res-symbol {
    min-width:0;height:17px;line-height:17px;
    font-size:17px;flex:none;
  }
  .resource-tile .res-data {
    display:flex;flex-direction:column;align-items:center;
    justify-content:center;gap:1px;
    min-width:0;width:100%;
  }
  .resource-tile .res-name {
    display:block;width:100%;
    font-size:clamp(8px,2.25vw,10px);
    font-weight:750;line-height:1.1;
    letter-spacing:-.12px;
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  }
  .resource-tile .res-amount {
    display:block;width:100%;font-size:clamp(9px,2.7vw,12px);
    font-weight:900;line-height:1.18;letter-spacing:-.35px;
    white-space:nowrap;overflow:visible;
  }
  .resource-tile .res-rate {
    display:block;width:100%;font-size:clamp(8px,2.25vw,10px);
    line-height:1.1;letter-spacing:-.12px;
    font-weight:750;white-space:nowrap;
  }
  .layout { flex:1;min-height:0;overflow:hidden; }
  .main {
    height:calc(100dvh - var(--space-header-height) - var(--resource-strip-height) - 64px);
    max-height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;
  }
  .section-head h1 { font-size:clamp(23px,6vw,30px); }
  .mobile-nav { height:64px; }
}
/* Little phones need a slightly smaller wordmark, not clipped labels. */
@media (max-width:355px) {
  .top-logo strong { font-size:10.7px; }
  .top-logo { gap:5px; }
  .top-actions { gap:2px; }
  .top-actions .icon-btn,.top-actions .help-circle,
  .top-actions .profile-btn { width:29px;min-width:29px; }
  .top-chip small { font-size:7px; }
  .resource-scope { min-width:105px; }
  .resource-strip { padding-left:4px;padding-right:4px; }
  .resource-rail { gap:3px; }
}
/* Better use of short landscape viewports. */
@media (max-width:760px) and (max-height:640px) {
  :root { --resource-strip-height:156px; --space-header-height:77px; }
  .topbar { grid-template-rows:37px 27px; }
  .top-resources .top-chip { height:27px; }
  .resource-strip-head { height:27px;min-height:27px; }
  .resource-tile .res-symbol { height:15px;line-height:15px;font-size:15px; }
  .resource-tile { gap:1px; }
}

@media (min-width:480px) and (max-width:760px) and (max-height:480px) and (orientation:landscape) {
  :root { --resource-strip-height:106px; }
  .resource-strip {
    display:grid;
    grid-template-columns:145px minmax(0,1fr);
  }
  .resource-strip-head {
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    align-content:center;
    height:auto;
  }
  .strip-heading { grid-column:1/-1; }
  .strip-heading .resource-orbit { display:none; }
  .resource-scope { width:100%;min-width:0; }
  .resource-scope button { padding:4px 3px; }
  .resource-expand { min-width:26px; }
  .resource-tile .res-symbol { display:none; }
}

/* Avoid overlapping credits / colony labels even on narrow 320px phones. */
@media(max-width:760px){
  .top-resources .top-chip > div { display:flex;flex-direction:column;align-items:flex-start;justify-content:center;gap:0;min-width:0; }
  .top-resources .top-chip small { font-size:7.5px;line-height:1.1;color:#c4b9dc; }
  .top-resources .top-chip strong { display:block;font-size:12px;line-height:1.2;max-width:100%; }
}
